Add unbound field to entity

Posts   
 
    
banusi
User
Posts: 43
Joined: 08-Jul-2006
# Posted on: 25-Jun-2008 16:39:34   

Hi

I have a problem

I have a table with a lot of columns, and mapped an enity to that.

I use the entitycollection to data bound to infragistics wingrid.

I have tried to add a unbound column in the grid directly, but it must be initialized with a value from another field.

And this is slow and not OO. Used initialierow with !e.ReInitialize but still slow.

So I wan't to add an unbound field to the entity itself. read/write to entity but not to database. I think I can find out to give it a default value (which come from another related enity).

I have found some info in the forum and it says, that it is simple, but no code showing how to actually do it.

So please show the code. Remember that it is an enity and it must work with an entitycollection and must be read / write.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 25-Jun-2008 16:46:42   

All you need to di is to add a property to the specified entity.

Hints: 1- Use a partial class file to add this property to maintain it across code generations. 2- If the property gets its value from some related entity's field, make sure you first check if the related field != null.

banusi
User
Posts: 43
Joined: 08-Jul-2006
# Posted on: 26-Jun-2008 07:58:38   

Thank you for the answer.

That was my first try and it did not work. The VS 2008 and the grid went down, but I must have made some mistake, because I have tried it again, and it works.

So the last thing. How can I get it a default value. Can I do this in the partial class?

banusi
User
Posts: 43
Joined: 08-Jul-2006
# Posted on: 26-Jun-2008 08:05:31   

Ok, I have look at the code and I think I can use InitClassEmpty or OnInitialized

Is that right?

banusi
User
Posts: 43
Joined: 08-Jul-2006
# Posted on: 26-Jun-2008 08:08:37   

Sorry. I am stupid this morning. At that moment, the other values have no value, because it gets the value form the db.

Sorry and thank you for the help.