0

我正在尝试创建一个地图以从以下查询中获取结果。我很难在 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") //
}
4

1 回答 1

0

如果您向我们展示您的 C# 代码并将 SQL 包装在 <code> 标记中,我们可以为您提供更好的答案...这是我您想要的猜测的猜测:

public class ProductMap : ClassMap<Product>
{
    Id(x => x.Id);
    References(x => x.Line); // Reference to Product_Line?
    // etc. 
}

public class ProductLineMap : ClassMap<ProductLine>
{
    Table("Product_Line");
    Id(x => x.Id).Column("cId");
    References(x => x.Product).Column("ProjId")
}
于 2010-09-02T09:53:36.860 回答