Hi nhusers,
i have a weird issue with linq for nhibernate(using nhibernate 3.1 and
fluentNH 1.2, both of them pulled via NuGet), i have mapped an object
model like this(simplified) with fluent nhibernate:
public class Property
{
public string PropertyId {get;set;}
public Broker Broker {get;set;}
public string Address1 {get;set;}
public int Price {get;set;}
public string Status {get;set;}
}
public class Broker
{
public string BrokerId {get;set;}
public string Name {get;set;}
}
Mapped like this with fluent nhibernate:
PropertyMap:
Id(p => p.PropertyId);
Map(p => p.... rest of the columns);
References(p => p.Broker).Not.Nullable();
BrokerMap:
Id(b => b.BrokerId)
Map(b => b.Name);
Now the problem is like this, these queries should be exactly the same
in my mind:
//criteria version
var test1 = session.CreateCriteria<Property>()
.SetFetchMode("Broker", FetchMode.Eager)
.Add(NHibernate.Criterion.Restrictions.Eq("Status", "T"))
.Add(NHibernate.Criterion.Restrictions.Gt("Price", 0))
.AddOrder(NHibernate.Criterion.Order.Asc("Address1"))
.SetFirstResult(100)
.SetMaxResults(100)
.List<Property>();
//linq version
var test2 = session.Query<Property>()
.Fetch(p => p.Broker)
.Where(p => p.Status == "T" && p.Price
> 0)
.OrderBy(p => p.Address1)
.Skip(100)
.Take(100)
.ToList();
Now the problem is that the criteria version is correctly _inner
joining_ the Property table with the Broker table when getting data,
but the linq version is doing a _left outer join_ which is not what i
want, i need that inner join. I would prefer to use linq instead of
criteria because of the refactoring problems and hardcoded text
strings you use in the criteria version.
So is this a bug in the linq provider for nhibernate or have i missed
something?
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.