I think I've encountered a bug when <join>'ing two tables using
WithTable() with lambda. Here's what I have.

// Schema
table PODetail
(
  PODetailID int identity(1,1) primary key
  PONumber varchar(15) foreign key (POHeader) references (PONumber)
  UnitOfIssue varchar(2) foreign key (UnitOfIssue) references (UICode)
)

table POHeader
(
  PONumber varchar(15) primary key
  TypeCode varchar(25)
)

table UnitOfIssue
(
  UICode varchar(2) primary key
  Description varchar(50)
)

// Model
public class PurchaseItem
{
  public virtual string UIDescription { get; set; }
  public virtual string TypeCode { get; set; }
}

// Mapping
public PurchaseItemMap()
{
  WithTable("PODetail");
  WithTable("UnitOfIssue", m =>
  {
    m.Map(x => x.UIDescription, "Description");
  });
  WithTable("POHeader", m =>
  {
    m.Map(x => x.TypeCode);
  });
}

// Generated Query (cleaned up)
SELECT
  d.PODetailID,
  ui.Description,
  h.TypeCode
FROM PODetail d
inner join UnitOfIssue ui
  on d.PODetailID=ui.PurchaseItemID
inner join POHeader h
  on d.PODetailID=h.PurchaseItemID

Note the incorrect join conditions. Is FNH not using the FKs defined
in my table to correctly generate the joins? Where is it getting
PurchaseItemID, which isn't defined anywhere in my code or schema?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to