如何将sql转换为动态linq核心

时间:2020-08-19 11:44:50

标签: c# entity-framework dynamic-linq-core

我有一个如下所示的SQL查询

public class GLB_Course
{
    [Key]
    public int GLB_CourseID { get; set; }
    public string GLB_CourseName { get; set; }
    [NotMapped]
    public IQueryable<GLB_CourseVesselType> GLB_Course_GLB_CourseVesselType { get; set; }
}

并且我想学习如何将上面的sql查询结果转换为下面的System.Linq.Dynamic.Core类结果。

 return GetList(filter).Select(x => new GLB_Course
            {
                GLB_CourseID=x.GLB_CourseID,
                GLB_CourseName = x.GLB_CourseName,
                GLB_Course_GLB_CourseVesselType = this.UnitOfWork.Context.Set<GLB_CourseVesselType>().Where(v => v.GLB_CourseID == x.GLB_CourseID && v.Deleted == false),
            }).Where(x=> x.GLB_Course_GLB_CourseVesselType.Where(c=> c.Deleted==false && c.VesselTypeID==2).Any(y=> y.GLB_CourseID==x.GLB_CourseID));
select * from table where DateTime BETWEEN DateA AND DateB

0 个答案:

没有答案