Hi all,
I'm currently using several classes with read-only properties (with a
getter only). These properties are pre-defined or calculated values,
which shouldn't be changed by my programm.
A example class looks as follows:
public class Customer {
private Guid customerId;
public Guid CustomerId {
get { return customerId; }
}
}
And my mapping file looks as follows (very simplified):
<class name="Customer" table="customer">
<property name="customerId" column="customerId" type="Guid"
access="field" />
</class>
Now I am working with LINQ to select my data with nHibernate. In
general the selects works fine, but I can't use any Where-clause,
because LINQ cannot resolve my public properties (Error Message "Could
not resolve property").
var query = from c in nhSession.Linq<Customer>()
where c.CustomerId = customerId
select c;
The exception seems correct for me, because in the mapping file I
specified my private field "customerId". LINQ on the other hand tries
to resolve my public property "CustomerId" which is not specified in
my mapping file.
My questions is now: Is the combination of field-mapping and LINQ
possible or are these both techniques are contradictory? Do I have to
use public properties (with full access getter/setter) for my mapping
to use the benefits of LINQ? Or is there a trick to use LINQ with my
private fields?
Thanks
-wesley
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---