public IEnumerable<ChildCate> GetChildCates()
{
var dc=new Models.DbContext();
var s = from t in dc.GetTable<ChildCate>()
where t.ParentID == ID
orderby t.ID descending
select new { t.Tag, t.Name, table = t };
return s;
}
上面会报错吧
解决方案新建一个实体类
public class Category
{
public int ID { get; set; }
public string Tag { get; set; }
public string Name { get; set; }
}
然后将第一段的代码改为:
public IEnumerable<Category> GetChildCates()
{
var dc=new Models.DbContext();
var s = from t in dc.GetTable<ChildCate>()
where t.ParentID == ID
orderby t.ID descending
select new Category{Tag=t.Tag,Name=t.Name,ID=t.ID};
return s;
}
大功告成:
支持小第网站:http://www.cnyolee.com