日期:2014-05-20 浏览次数:20999 次
class Category()
{
public int Id {get;set;}
public int ParentId {get;set;}
public string Name {get;set;}
}
select c.*, p.Name as ParentName from Category as c left join Category as p on c.ParentId = p.Id where c.Id=1
from c in Category.Where(c => c.Id == 1)
join p in Category
on c.ParentId equals p.Id into cates
from cate in cates.DefaultIfEmpty()
select new
{
c,
ParentName = p.Name
};
from c in Category.Where(c => c.Id == 1)
join p in Category
on c.ParentId equals p.Id into cates
from cate in cates.DefaultIfEmpty()
select new
{
c,
ParentName = cate.Name
};
------解决方案--------------------