C# 指定的成员';索赔类型ID';在LINQ to实体中不支持
目前我有一个错误,它阻止我从数据库返回任何数据。我通过了LINQ连接,然后当我将鼠标悬停在保存数据的模型上时,它会显示错误消息。我确实注释掉了连接中的几行,它起作用了,所以我已经确定了错误在哪里。我只是需要一些帮助来理解这个错误以及它发生的原因 SQL存储库:C# 指定的成员';索赔类型ID';在LINQ to实体中不支持,c#,linq,C#,Linq,目前我有一个错误,它阻止我从数据库返回任何数据。我通过了LINQ连接,然后当我将鼠标悬停在保存数据的模型上时,它会显示错误消息。我确实注释掉了连接中的几行,它起作用了,所以我已经确定了错误在哪里。我只是需要一些帮助来理解这个错误以及它发生的原因 SQL存储库: public IQueryable<ClaimNumberReport> GetClaimsByClaimNumber(int ClientID, int ClaimID) { return (from
public IQueryable<ClaimNumberReport> GetClaimsByClaimNumber(int ClientID, int ClaimID) {
return (from d in camOnlineDb.Details
join a in camOnlineDb.Areas
on new { a = d.ClientID, b = d.AreaID ?? 0 }
equals new { a = a.ClientID, b = a.AreaID }
where d.ClientID == ClientID
join r in camOnlineDb.Reasons
on new { a = d.ClientID, b = d.ReasonID ?? 0 }
equals new { a = r.ClientID, b = r.ReasonID }
join sd in camOnlineDb.SuppDepts
on new { a = d.ClientID, b = d.CategoryID ?? 0 }
equals new { a = sd.ClientID, b = sd.CategoryID }
join h in camOnlineDb.Headers
on new { d.ClientID, d.ClaimID }
equals new { h.ClientID, h.ClaimID }
where d.ClaimID == ClaimID
join su in camOnlineDb.Suppliers
on new { h.ClientID, h.SupplierID }
equals new { su.ClientID, su.SupplierID }
join cp in camOnlineDb.ClaimPacks
on new { h.ClientID, h.ClaimID }
equals new { cp.ClientID, cp.ClaimID }
join rev in camOnlineDb.Reviews
on new { h.ClientID, h.ReviewID }
equals new { rev.ClientID, rev.ReviewID }
join revp in camOnlineDb.ReviewPeriods
on new { a = rev.ClientID, b = rev.ReviewPeriodID ?? 0 }
equals new { a = revp.ClientID, b = revp.ReviewPeriodID }
join st in camOnlineDb.Statuses
on new { a = d.ClientID, b = d.StatusID ?? 0 }
equals new { a = st.ClientID, b = st.StatusID }
join stcm in camOnlineDb.StatusCategoryMappings
on new { st.ClientID, st.StatusID }
equals new { stcm.ClientID, stcm.StatusID }
join stc in camOnlineDb.StatusCategories
on new { stcm.StatusCategoryID }
equals new { stc.StatusCategoryID }
select new ClaimNumberReport {
// Changed type to sub type and dropped type
TypeID = d.ClaimTypeID,
// Needs changed to PDF file address
CPAttached = cp.Comment,
ReviewName = revp.ReviewPeriodName,
ClaimID = d.ClaimID,
Line = d.ClaimLine,
AccountNo = su.AccountNo,
SupplierName = su.SupplierName,
Amount = d.Amount,
Status = st.StatusDesc,
DateSent = d.DateSent,
DayOS = d.DaysOS,
NominalPeriod = d.NominalPeriod,
SLInvoiceNo = d.SLInvoiceNo,
Area = a.AreaDesc,
DebitRef = d.DebitFile,
DebitDate = d.JournalDate,
DeductDate = d.DeductDate,
StatusCategoryDesc = stc.StatusCategoryDesc,
APLReason = r.ReasonDesc,
DeptNo = sd.DepartmentID,
DeptName = sd.DepartmentName,
// The below 4 need to change, I believe that this may be done on the view or controller.
//Settled = d.Amount,
//Cancelled = d.Amount,
//Conversation = d.Amount,
//WIP = d.Amount
});
}
ClaimNumberReportClass:
public class ClaimNumberReport {
public int ClaimID { get; set; }
public string ReviewName { get; set; }
public char? TypeID { get; set; }
public char OldTypeID { get; set; }
public string CPAttached { get; set; }
public int? Line { get; set; }
public string AccountNo { get; set; }
public string SupplierName { get; set; }
[DataType(DataType.Currency)]
public decimal? Amount { get; set; }
public string Status { get; set; }
public DateTime? DateSent { get; set; }
public int? DayOS { get; set; }
public int? NominalPeriod { get; set; }
public string SLInvoiceNo { get; set; }
public string Area { get; set; }
public string DebitRef { get; set; }
public DateTime? DebitDate { get; set; }
public DateTime? DeductDate { get; set; }
public string StatusCategoryDesc { get; set; }
public string APLReason { get; set; }
public int ClientID { get; set; }
public int DeptNo { get; set; }
public string DeptName { get; set; }
[DataType(DataType.Currency)]
public decimal Settled { get; set; }
[DataType(DataType.Currency)]
public decimal Cancelled { get; set; }
public decimal Conversation { get; set; }
[DataType(DataType.Currency)]
public decimal WIP { get; set; }
}
当我到达视图并尝试显示数据时,它会显示错误消息,但当我将鼠标悬停在模型的返回视图行上时,它会显示错误消息。这与数据类型char有关。在我的数据库中,ClaimTypeID是一个字符。但是,在VisualStudio中,字符与SQL字符不同,因为它只允许一个字符。因此,我不得不将其改为字符串。我一直在使用该线程,它似乎没有给我多少帮助您在
getclaimsbycaimnumber
中遇到错误?是ClaimTypeID
您的类的成员Details
?@MairajAhmad我在视图中看到了错误。但是是的,ClaimTypeID是我的Details类的成员。它是可以为空的,就像在SupportDepts类排序中一样char
不是实体框架中的。它在C#和.NET中完全有效,但EF将任何字符类型(甚至char(1)
)映射到字符串。
public class ClaimNumberReport {
public int ClaimID { get; set; }
public string ReviewName { get; set; }
public char? TypeID { get; set; }
public char OldTypeID { get; set; }
public string CPAttached { get; set; }
public int? Line { get; set; }
public string AccountNo { get; set; }
public string SupplierName { get; set; }
[DataType(DataType.Currency)]
public decimal? Amount { get; set; }
public string Status { get; set; }
public DateTime? DateSent { get; set; }
public int? DayOS { get; set; }
public int? NominalPeriod { get; set; }
public string SLInvoiceNo { get; set; }
public string Area { get; set; }
public string DebitRef { get; set; }
public DateTime? DebitDate { get; set; }
public DateTime? DeductDate { get; set; }
public string StatusCategoryDesc { get; set; }
public string APLReason { get; set; }
public int ClientID { get; set; }
public int DeptNo { get; set; }
public string DeptName { get; set; }
[DataType(DataType.Currency)]
public decimal Settled { get; set; }
[DataType(DataType.Currency)]
public decimal Cancelled { get; set; }
public decimal Conversation { get; set; }
[DataType(DataType.Currency)]
public decimal WIP { get; set; }
}