c# - Which of these work in nhibernate? -


i'm start digging nhibernate , i'm hoping can give me little head start here.

i believe poco's must have parameterless public constructor (?). , child related collections, use ilist (although i've seen ibag in examples) (?)

i'm interested in access can give or deny publicly on objects. here's example:

public class poco {     private ilist<childpoco> _childpocos;      //1) can use ienumerable? or have use ilist? or third way?     public ienumerable<childpoco> childpocosenumerable     {         { return _childpocos.asenumerable(); }     }  }  public class childpoco {     private string _name;     public string name     {         { return _name; }         //2) protected/public/private set?     } } 

so, above can see //1) , //2) can explain options here nhibernate support?

a little info if helps. desire @ 1) use ienumerable make public face of collection read only.

the same true of 2) name. i'd read here.

the reason asking i've got facilities build out pocos @ moment, won't able start on nhibernate stuff until later i'm trying plan ahead little.

thanks.

1) interfaces can use depend on collection type.

for bag can use ienumerable<t>, icollection<t> or ilist<t>.

for set can use ienumerable<t>, icollection<t> or iesi.collections.generic.iset<t>.

for list must use ilist.

now, asenumerable noop. if want prevent client code modifying collection, use identity select instead:

public ienumerable<childpoco> childpocos {     { return _childpocos.select(x => x); } } 

and map it, use access="field.camelcase-underscore". cause nhibernate use _childpocos field childpocos persistence

2) setter can have accesibility want. , don't need use backing field:

public string name { get; private set; } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -