I have this basic entity setup:
public class Instrument
{
public virtual int Id { get; set; }
public virtual Guid? InstrumentGuid { get; set; }
public virtual string FIPSCode { get; set; }
public virtual IList Names {get; set;}
}
public class Name
{
public virtual int Id {get; set;}
public virtual string Name {get; set;}
public virtual Instrument Instrument {get; set;}
}
Mappings:
public class InstrumentMap: ClassMap<Instrument>
{
public InstrumentMap()
{
Id(x => x.Id);
Map(x => x.InstrumentGuid).Not.Nullable();
Map(x => x.FIPSCode).Not.Nullable();
HasMany(x => x.Names).Casecade.All;
}
}
public class NameMap : ClassMap<Name>
{
public NameMap()
{
Id(x => x.Id);
Map(x => x.Name);
References(x => x.Instrument);
}
}
So why is it that when I do these two queries do I get different results?
var namelist = from name in Session.Linq()
where name.Instrument.Id == 1
select name;
I get 3 results, 2 where Instrument.Id = 1 and 1 where Instrument.Id = 4 vs:
var querystr = "select name From Name as name where name.Instrument.Id = 1";
var hqlresult = Session.CreateQuery(querystr).List();
This gets only the 2 results where Instrument.Id = 1.
Could someone explain where the Id = 4 is coming from in the Linq query, or is NHibernate.Linq not quite stable yet? Thanks!