我亞音速3.0 SimpleRepository玩耍,並試圖讓菜單和的菜單項與一個LINQ查詢,但的菜單項是空永諾亞音速3.0和LINQ
菜單
public class Menu
{
public Menu()
{
MenuId = 0;
MenuName = "";
MenuItems = null;
}
public int MenuId { get; set; }
public string MenuName { get; set; }
public MenuItem MenuItems { get; set; }
}
菜單項
public class MenuItem
{
public MenuItem()
{
MenuItemId = 0;
MenuId = 0;
MenuItemName = "";
}
public int MenuItemId { get; set; }
public int MenuId { get; set; }
public string MenuItemName { get; set; }
}
Linq查詢
var menus = from m in _repo.All<Menu>()
from mi in _repo.All<MenuItem>()
where m.MenuItems.MenuItemId == mi.MenuItemId
select new Menu
{
MenuId = m.MenuId,
MenuName = m.MenuName,
MenuItems = {
MenuItemId = mi.MenuItemId,
MenuItemName = mi.MenuItemName
}
};
有人能告訴我我在做什麼錯嗎?
它是:「if(type.Name.Contains(」AnonymousType「)」還是它:「if(resultType.IsValueType)」需要放出? – 2009-11-04 09:04:09
if(type.Name.Contains(「 AnonymousType「)|| type.Name.StartsWith(」Grouping「)... that line。 – 2009-11-04 17:38:18
這是否解決了您的問題? – 2009-11-20 09:41:26