Getting IEntityField2 from id

Posts   
 
    
msjonathan
User
Posts: 9
Joined: 05-Jan-2010
# Posted on: 25-Jan-2010 11:20:00   

hej hej,

I have the following problem have to add a EntityField2 in a sortedList. Like this:


SortedList<EntityField2, object> Keys = new SortedList<EntityField2, object>();
Keys.Add(EmployeeFields.ExternalId, "52255");

This works. Right now I want to do this dynamically I have the FieldID from the field.

Can I retrieve the EntityField2 from its id?

I have a class ImportColumn * int FieldId, * string Value,

And now I want to foreach a list of ImportColumns and add the corresponding EntityField2 and his/here value in the sorted list.

simple_smile can someone help me?

Greetz

Jonathan

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Jan-2010 14:12:33   

I'm not sure I 100% understand you. Would you please re-phrase your question or provide more details?

Also if you can provide a little background on why do you need this, maybe there are other alternatives.

msjonathan
User
Posts: 9
Joined: 05-Jan-2010
# Posted on: 25-Jan-2010 14:32:46   

Hi,

I need to write an import for an existing application. I have an ascii file with data:


FirstName,LastName
FistName2,Lastname2

I have an entity: Employee, and want to create 2 employees with the data from the ascii file.

the problem is: In the BL part of the application I fill an object with the ID of a field: ex (Field: ExternalID there from the id : 5 ). I got the id from some HelperClasses generated by LLBLGen. I can't add an EntityField2 because this is BL part of application and does not know anything of the DB.

**EDIT: This is not exactly correct, The BL knows all about DB, but my object in the BL inherits from an interface in a different project, and there is now knowledge about anything concerning LLBLGen/DB **

the existing creating code of an employee needs the Field ex(EmployeeFields.FirstName) & (EmployeeFields.LastName) and value, I have to put it in a sorted list and give it to the function.

So I have the ID from the IEntityField2 and the type of Entity. Is there any dynamic way to create the IEntityField2 from its id?

Because later on it's not only firstName, lastname but also other fields (address,mail, .....)

Greetz

Jonathan

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 25-Jan-2010 15:08:38   

Where do you store that Id of the field? (from where do you get the value 5 in the above example).

I think the idea can be simpler: You store the value of the fields of an entity in a text file, in the order of their existence in the entity.Fields collection.

Then using the same order you can re-fill the fields' values again from the text file.