2

Need some help or some advice with entity framework v4.

As you already know, EF v4 does not support lazy loading of scalar properties. If I have some entity object for example Order in model with many scalar properties, some of them expensive to load from DB, like attached file for example.

As I found later, it is possible to move these expensive properties to another entity for example Order1 and remap them to DB table. So original DB table will be mapped to 2 entities - Order - with properties ID and Name and Order1 - with all others.

What I need to do? In User Interface I will have a ListBox filled with entity Order (ID - Name of all orders) on left side and all other expensive properties of Order1 on right side for clicked order in listbox. Properties from Order1 lazy loaded, and with working savechanges, delete objects etc ... .

How to make business object for order as entities are separated and how to setup with wpf binding?

thanks

1 Answer 1

1

Having 2 models complicates your program, and can be a source of bugs. I would rather use a single model and then selectivily load items as I needed them.

I meant use only one entity framework model. Looks like you are doing this already. What you need to do in to explicitly load data when you need it, see http://msdn.microsoft.com/en-us/library/bb896249.aspx.

This is actually a design desision from MS, to force you to be aware of which data you need at which times. With automatic lazy loading it works, but then you can get into problems later due to scaling issues.

Sign up to request clarification or add additional context in comments.

1 Comment

you mean 2 entities for same DB table? or 2 entity framework models? I have only 1 entity framework model. How selectively load items? when i have only one entity for Order DB table, i can load 2 collumns like this var query = db.Order.Select(o => new { IDorder = o.IDorder, Name = o.Name }) .ToList().Select(x => new Order{IDorder = x.IDorder, Name = x.Name}); but with such query savechanges is not working because of context ... .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.