How do create EntrySet Dynamic?

Posts   
 
    
Romanp
User
Posts: 17
Joined: 09-Aug-2006
# Posted on: 18-Nov-2006 13:50:17   

Hello

Short queston :-)

How i can create Entity dynamic?

Dim customer As New CustomerEntity()

Thanks Roman

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 18-Nov-2006 20:39:15   

Roman, I'm not quite sure what you're asking. What do you mean by "Entity dynamic"? Do you mean how to create a new entity? That's what your line of code suggests, but I'm not sure.

Also, tell us what version of LLBLGen Pro you are using, what database drivers, and which template type you are using. Thanks.

Romanp
User
Posts: 17
Joined: 09-Aug-2006
# Posted on: 19-Nov-2006 17:17:29   

Sorry if i dont make it clear so a small example

LLBL Gen latest version

DB shoud be not important for this question :-)

Function CreateNewEntry(entryName) 'here how to create the entry ? follow the entryName?

End Function

Regards

Roman

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 20-Nov-2006 00:31:40   

EntryEntity myEntry = new EntryEntity();
myEntity.SomePKField = 123;
myEntity.SomeStringField = "Anything";
myEntity.Save();

This is using the Self-Servicing template. Adapter is different. I'd suggest reading the documentation section on "Using the generated code".

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 20-Nov-2006 10:31:09   

ALso check out the entity factory classes (e.g. CustomerEntityFactory) which allow you to create a new instance.

Frans Bouma | Lead developer LLBLGen Pro
Romanp
User
Posts: 17
Joined: 09-Aug-2006
# Posted on: 22-Nov-2006 09:00:58   

Hello Guys thanks for the input but I guess I make myself not very clear sorry about that.

I will explain in more detail what I want to do.

Example I have 3 Entrys

CustomerEntrys AddressEntrys ProductEntrys

Now I have an Webservice Function that receive XML and read with readXML into the Entrys.

But now i need to have 3 Functions for each Entry or need to do like that


Function SaveEntry(ByVal entryName As String, ByVal entryXml As String) 
    Select Case  Entrys 
      Case "Customer"
           Dim Customer As New CustomerEntity()
           .......
      Case "Address"
             Dim Address As New AddressEntity()
             .......

I look for a smarter solution to be more fleaxible is possible,

Thanks

Roman

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 22-Nov-2006 09:48:11   

If you pass the EntityType value (EntityType is the enum defined in ConstantsEnums with all the entities), you can use that enum value with teh GeneralEntityFactory class to create a new instance. The GeneralEntityFactory is generated in the entityfactories.cs file.

Frans Bouma | Lead developer LLBLGen Pro
Romanp
User
Posts: 17
Joined: 09-Aug-2006
# Posted on: 23-Nov-2006 06:31:11   

smile Thank you so much Otis, that is what i'm searching for.

Roman