0

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 ??

1 Answer 1

1

(I hope I've understood your question correctly.)

The relations in your database are always defined in database types, probably either an int or a uniqueidentifer in 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 the Id (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 a JOIN for you automatically and returns the relational information as an object hierarchy, instead of just a set of id values.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.