Now I found the problem. Here is the explanation:

public class Foo
{
  private string status;
  public StatusEnum
  {
                get
                {
                        if(status == "A")
                                return StatusEnum.Available;
                        else
                                return StatusEnum.NatAvailable;
    }
    set
                {
                        if(value == StatusEnum.Available)
                                status = "A";
                        else
                                status = "NA";
                }
        }
}

The important part of the mapping

<property column="Status" type="String" name="status" not-null="true"
access="field"/>


So, I was filtering some data with Linq2NH and an exception was
thrown:

"could not resolve property: Status of: FooNameSpace.Foo"

Then I tried a simple Criteira

ICriteria cr = session.CreateCriteria(typeof(Foo));
cr.Add(Expression.Eq("Status", StatusEnum.Available));

And got the same exception. I thought that NH was not using the field
as I mapped but...

ICriteria cr = session.CreateCriteria(typeof(Foo));
cr.Add(Expression.Eq("status", "A"));

And it worked - of course - NHibernate is accessing the field as I
told it to do.

Using Criteria is easy to make it work but using Linq2NH I don't see
how.
Maybe the way Fabio told me before, but I didn't want to referece D9
assemblies and create
a custom attribute (since I already use Description Attribute ) for
this.

On Jun 15, 8:15 pm, CassioT <[email protected]> wrote:
> OK. I will investigate more and come back later.
>
> On Jun 15, 6:46 pm, Fabio Maulo <[email protected]> wrote:
>
>
>
> > 2009/6/15 CassioT <[email protected]>
>
> > > So, why it doesn't use the field value to query?
>
> > I have the same question... without mappings, classes and query is hard to
> > answer.
> > What I'm pretty sure is that we have specific tests for that situation and
> > our tests does not fail.
>
> > --
> > Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to