views:

292

answers:

1

I have Entity-Attribute-Value (EAV) database. Entity in this sense has nothing to do with entities in EF but merely refers to some "thing" about which you are storing information. You store a value in the Value table, which is associated with an Attribute (the name of the information) and an Entity.

In the EAV model, you don't store NULL values. For a given combination of {Entity,Attribute}, the absence of an entry in the Value table implies NULL.

Because of this, the Data column (say it's type Int) in the Value table is not nullable. This is a constraint I must deal with. I can't change it.

I'm building a WPF app and want to have an Value entity bound to a text box. If, on saving, the text box is empty, I need to ensure that the bound entity does not get included in the save (because that will write a 0 in the table, which is incorrect). If the text box is not empty, obviously the data should be saved.

I was experimenting with detaching and re-attaching the entity based on the value of the text box, but am getting errors having to do with the relationship objects.

Any ideas on how I can achieve what I'm trying to do?

+1  A: 

When you atach an object you also have to attach the reference to othe entities this object have...

moi_meme