Create an entity given only a collection type or a string

Posts   
 
    
Darren166
User
Posts: 41
Joined: 30-Jan-2007
# Posted on: 09-Mar-2007 20:41:32   

Hi, is it at all possible to create a standalone entity if you are given a collection? Or to extract an entity from it by it's primary key?

My situation is that I have a datasource bound to a gridview and I need to be able to access the particular entity that was selected, however I do not know the entitycollection that was used to create the datasource as it came from a dropdown list. (It could be one of about 20)

I have the entity name as a string and I have the collection of entities that was used to generate the datasource, I also have the primary key value of the selected entity, I just don't have the entity itself. Is there any way to get this from the collection, or perhaps to create an entity based only on the string version of its name?

Not sure I have explained this very well!

Thanks,

Darren

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 09-Mar-2007 23:08:23   

I think this thread will get you what you want:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7666

Darren166
User
Posts: 41
Joined: 30-Jan-2007
# Posted on: 10-Mar-2007 18:53:56   

Thanks for that, it is a good method.

However, I cannot then access a method of that entity that is specific to it. For example, I have an entity "Colour" which has a method "GetUsage". Using the code above I will have an entity of type IEntity and will not be able to access the GetUsage method. Is there any way around this?

Thanks in advance,

Darren

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Mar-2007 04:19:23   

Darren166 wrote:

Hi, is it at all possible to create a standalone entity if you are given a collection? Or to extract an entity from it by it's primary key?

What about EntityCollection.FindMatches(IPredicateFilter filter), where **_filter _**specify the Entity's PK? Ref: LLBLGenProHelp - Generated code - Using the entity collection classes - (Adapter || SS) - Finding entities inside a fetched entity collection

David Elizondo | LLBLGen Support Team