SelfServicing equiv. of EntityFactoryToUse.CreateFields

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 16-Jun-2004 23:20:46   

How can I get the IEntityFields collection from a collection using Self Servicing? I'm trying to get http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=796 to work with self servicing...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 17-Jun-2004 10:35:37   

You can grab the Fields from the first object in the collection:

IEntityFields fields = myCustomers[0].Fields;

as every entity has a collection of these. Use these to create a column set. You then can walk through the objects and per object through their fields by looping through myEntity.Fields.

However I think it's often more efficient to simply refetch the data in a datatable, use the method GetMultiAsDataTable() which is a static (shared) method of every entity collection.

Frans Bouma | Lead developer LLBLGen Pro
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 17-Jun-2004 14:43:14   

Otis wrote:

You can grab the Fields from the first object in the collection:

IEntityFields fields = myCustomers[0].Fields;

as every entity has a collection of these. Use these to create a column set. You then can walk through the objects and per object through their fields by looping through myEntity.Fields.

However I think it's often more efficient to simply refetch the data in a datatable, use the method GetMultiAsDataTable() which is a static (shared) method of every entity collection.

Well, as you may have read in my other posts, the problem is that I need to be able to work with the data before I get it to the datatable. I could, of course, get the datatable and work directly on that, but it's so much more convenient to use the entity and collection objects from llblgen.

I'll see if I can use your suggestion to get the function working, then I'll post it here in case anyone else needs it.

Trig
User
Posts: 96
Joined: 09-Jun-2004
# Posted on: 17-Jun-2004 15:09:39   

Like I said in response to your other post, you can just work with the base classes directly without tying it to a strongly typed class. Use the Fields property of the EntityBase class which returns an IEntityFields. You can enumerate through the fields using an IEntityField object, which will give you all the info about the columns you need to create for the DataTable.