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

相关文章:

  • 2022-12-23
  • 2022-03-06
  • 2021-11-05
  • 2021-11-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-02-11
相关资源
相似解决方案