我有一个问题,这个LINQ NHibernate的查询预先加载问题
var listeShopping = (from cart in session.Query<Cart>()
.Fetch(cart => cart.ItemShopping)
.ThenFetch(item => item.Manufacturer)
select cart.ItemShopping).ToList<ItemShopping>();
当我启动它我有一个奇怪的错误:
Query specified join fetching, but the owner of the fetched association was
not present in the select list [FromElement{explicit,not a collection join,
fetch join,fetch non-lazy properties,classAlias=_1,role=,tableName= (...)
我需要预先加载,怎么能我避免了那个错误?如果可以提供帮助,我会提及我只使用内部连接表来使用购物车表。我只需要知道购物车中的ItemShopping。
问候
编辑
我修改了代码,使其在英语可读的。我纠正了错误。
编辑2
我发现方法,它似乎工作...有人可以检查它,如果我没有做错误?
var list = (from item in session.Query<ItemShopping>()
.Fetch(item => item.Manufacturer)
from cart in item.Cart
select item).ToList<ItemShopping>();
“select”中的“pan”定义在哪里? – Variant 2011-06-07 09:14:20
您正在查询购物车,从潘选择的东西,并试图将其转换为项目购物列表...一些细节需要:) – Sly 2011-06-07 09:16:29
我修改了代码...对不起! – 2011-06-07 09:25:32