c# - How can I convert an EF4 Code-First ICollection to an EntityCollection? -


say have following entity:

public class post {     public int id { get; set; }     public virtual icollection<comment> comments { get; set; } } 

when retrieve post object database, need convert comments collection entitycollection<t> can check ef4 related data collection, such if data eager loaded or not.

unfortunately, if try direct cast icollection<t> entitycollection<t>, exception due fact comments property system.collections.generic.list<t> , cannot converted entitycollection<t>.

so how go getting ef information on collection when using code-first?

this might more appropriate comment, i'm hoping ef4 guru can respond , explain what's going on. asked question below while ago, on ctp4. 1 response author of ef 4 recipes, saying @ runtime collection created entitycollection if declared virtual , icollection (which questioner doing) that's not happening.

also, rowan miller (who's on ef4 team) wrote more advanced option, questioner has indicated not work. what's going on here? current ctp not support this, while previous 1 does?

using createsourcequery in ctp4 code first


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -