我正在尝试创建一个地图以从以下查询中获取结果。我很难在 where 条件下设置产品映射以在 3 列上设置对 Product_Line 的引用。如何使用 fluent 实现这一目标?
产品表:cId、ProjID、Line等,列 Product_Line表:cId、ProjID、Line等,列
select f.* from Product f join Product_Line v on f.cId = v.CId and f.ProjID = v.ProjID and f.line = v.line
提前致谢。拉杰什
首先,感谢您查看它并在此处提供更多信息://Req:我想查询产品,如果没有 ProductLine,那么我想创建一个 ProductLine,如果有,那么我会更新它.
public class ProductMap : ClassMap<Product>
{
Id(x => x.Id);
Map(x => x.CustomerId, "CustId");
Map(x => x.ProjId, "PROJId");
Map(x => x.LineNumber, "LineNumber");
Map(x => x.ReportType, "ReportType");
// Reference to Product_Line? - this reference should be based on three columns (custId, ProjId, LineNumber)
References(x => x.Line);
}
public class ProductLineMap : ClassMap<ProductLine>
{
Table("Product_Line");
Map(x => x.CustomerId, "CustId"); //same column as Product.CustId
Map(x => x.ProjId, "PROJId"); //Same as Product.ProjId
Map(x => x.LineNumber, "LINENUMBER"); //Same as Product.LineNumber
//etc.,
//for me, this reference is not needed as I need from Product to ProductLine - one way.
//References(x => x.Product).Column("ProjId") //
}