Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EntityFramework.SqlServer.dll中发生类型为“System.NotSupportedException”的异常_C#_.net_Sql Server_Entity Framework - Fatal编程技术网

C# EntityFramework.SqlServer.dll中发生类型为“System.NotSupportedException”的异常

C# EntityFramework.SqlServer.dll中发生类型为“System.NotSupportedException”的异常,c#,.net,sql-server,entity-framework,C#,.net,Sql Server,Entity Framework,我试图使用联接获取数据,但在获取ParentHireGroupName时显示错误。当我对这行代码进行注释时,它工作得很好 作用 其他错误信息: 无法比较“HireGroup”类型的元素。仅支持基元类型、枚举类型和实体类型。以下链接解释了错误和解决方法。虽然这两个问题的场景可能有所不同,但是使用linq到sql! public IList<RptFleetHireGroupDetail> GetFleetReport() { var fleetH

我试图使用联接获取数据,但在获取ParentHireGroupName时显示错误。当我对这行代码进行注释时,它工作得很好

作用

其他错误信息:
无法比较“HireGroup”类型的元素。仅支持基元类型、枚举类型和实体类型。

以下链接解释了错误和解决方法。虽然这两个问题的场景可能有所不同,但是使用linq到sql!
public IList<RptFleetHireGroupDetail> GetFleetReport()
        {
            var fleetHireGroupDetailQuery = from vehicle in DbSet                
                join hgd in db.HireGroupDetails on
                    new {ModelID = vehicle.VehicleModelId, MakeID = vehicle.VehicleMakeId, CategoryId = vehicle.VehicleCategoryId, Year= vehicle.ModelYear }
                    equals new { ModelID = hgd.VehicleMakeId, MakeID = hgd.VehicleMakeId, CategoryId = hgd.VehicleCategoryId, Year = hgd.ModelYear }
                select new RptFleetHireGroupDetail
                {
                    HireGroupName = hgd.HireGroup.HireGroupName,
                    PlateNumber = vehicle.PlateNumber,
                    ParentHireGroupName = hgd.HireGroup.ParentHireGroup!=null? "kuch to hai":string.Empty,

                };
            return fleetHireGroupDetailQuery.OrderBy(fhgd => fhgd.FleetPoolName).ToList();
        }
public class RptFleetHireGroupDetail
    {
        #region Public
        public string HireGroupName { get; set; }
        public string ParentHireGroupName { get; set; }
        public string PlateNumber { get; set; }
        #endregion
}