I rewrite application from ASP.NET to Silverlight and use NHibernate 2.
Tables in my db looks like this:
alt text http://img268.imageshack.us/img268/4940/tablesqp.jpg
In Dziecko table I have reference to id of Opiekun and Grupy. In ASP it’s ok for me but in videos Summer with NHibernate I see that Stephen Bohlen in exchange use object of this type, for me its Opiekun and Grupy.But in SQL Server I can’t define object type, so better is map only this id[will I could problem querying for id] and or something else ?? Using all object of specific type is efficiency? We must query all object in exchange only int type of id’s ??
(I hope I’ve understood your question correctly.)
The relations in your database are always defined in database types, probably either an
intor auniqueidentiferin the case of foreign key columns. The database should know nothing of the data transfer objects NHibernate returns to your application code.When you map the foreign key columns in your data transfer objects using
ManyToOne, etc., you specify the type of the object because NHibernate knows that the relation is always going to be between the foreign key column you specify in the attribute, and theId(primary key) of the object type to be returned. This saves you the trouble of doing extra queries to return parent or child entities — NHibernate just does aJOINfor you automatically and returns the relational information as an object hierarchy, instead of just a set of id values.