首页 > 解决方案 > 使用 linq 从实体框架核心获取 {"error":"Null TypeMapping in Sql Tree"}

问题描述

我有这个 linq 选择语句,我得到了这个错误 {"error":"Null TypeMapping in Sql Tree"} 回来。

生病将代码放在下面,但有没有办法获得有关问题所在的更多信息?如果您需要这些实体,请告诉我,我会复制它们。

问候

var query = from o in _orderDataDbContext.tblSellFlangeOrders
            join od in _orderDataDbContext.tblSellFlangeOrderDetails
            on (int?)o.Id equals od.SellFlangeOrderId
            join t in _orderDataDbContext.tblTypes
            on od.TypeId equals (int?)t.Id
            join l in _orderDataDbContext.VLegendeFlangeLengths
            on od.LengthId equals (int?)l.Id
            join g in _orderDataDbContext.VLegendeGrades
            on od.GradeId equals (int?)g.Id
            where o.Id == request._flangeOrderID
                        select new FlangeOrderDetailByPoCodeDto
                        {
                            SellFlangeOrderID = o.Id,
                            DetailID = od.Id,
                            Price = od.Price1000,
                            BF = od.Bf,
                            TypeID = t.Id,
                            Type = t.Inches1 + "x" + t.Inches2,
                            LengthID = l.Id,
                            Length = l.Length + "'" + l.OverLength + "\"",
                            GradeID = g.Id,
                            Grade = g.Grade
                        };

标签: asp.net-coreentity-framework-corelinq-to-entities

解决方案


在运行正常的代码中升级到 .net core 3.1 后,我遇到了类似的问题。

最后,问题就像您在这里遇到的那样:

Length = l.Length + "'" + l.OverLength + "\"",

似乎您无法连接 int、decimal 等...所以您必须将它们转换为字符串

Length = l.Length.ToString() + "'" + l.OverLength.ToString() + "\"",

推荐阅读