NHibernate and Auto-Properties

669 views
Skip to first unread message

FrancK

unread,
Apr 9, 2009, 7:04:54 AM4/9/09
to nhusers
Hi all,
Can I use autoproperties with NHibernate especially with simple
attributes (string, int), object references and collections ?

ex:
public virtual string CustomerId { get; set; }
public virtual string Label { get; set; }
public virtual Address { get; set;}
public virtual ISet Orders { get; set; }

Because I get the following error:
NHibernate.PropertyNotFoundException: Could not find a getter for
property 'Address' in class 'Modele.Address'

Maik

unread,
Apr 9, 2009, 7:40:05 AM4/9/09
to nhusers
Is Address a Type?
Then a PropertyName is missing....

Try it like this!
public virtual Address AnAddress{ get; set;}

Stefan Sedich

unread,
Apr 9, 2009, 8:16:23 AM4/9/09
to nhu...@googlegroups.com
What does your mapping look like?


Cheers

Stefan Sedich

Fabio Maulo

unread,
Apr 12, 2009, 10:08:49 AM4/12/09
to nhu...@googlegroups.com
Yes you can and you can even use 'backfield' as access-strategy (for example when you have private accessor for setter).

2009/4/9 FrancK <email...@gmail.com>



--
Fabio Maulo

Garfield

unread,
Apr 13, 2009, 2:25:52 PM4/13/09
to nhusers
I have been using this since we upgraded to .Net 3.5 & NHibernate 2.0,
and it works great. Files are so much cleaner now.

On Apr 12, 10:08 am, Fabio Maulo <fabioma...@gmail.com> wrote:
> Yes you can and you can even use 'backfield' as access-strategy (for example
> when you have private accessor for setter).
>
> 2009/4/9 FrancK <email.fx...@gmail.com>
Reply all
Reply to author
Forward
0 new messages