Nbernate assumes that all your properties, unless specified otherwise, are lazy-loaded What that means is that, in your case, the JokeCategory isn't pulled from the DB whenever you pull your Joke object; instead, a 'proxy' is generated dynamically The first time you access that property nbernate knows to pull it from the DB. (this is how nb's lazy-loading works).
Nbernate assumes that all your properties, unless specified otherwise, are lazy-loaded. What that means is that, in your case, the JokeCategory isn't pulled from the DB whenever you pull your Joke object; instead, a 'proxy' is generated dynamically. The first time you access that property nbernate knows to pull it from the DB.(this is how nb's lazy-loading works) So basically what's going on here is that you expect your JokeCategory to be of type JokeCategory, but since it isn't really initialized- it's of type Proxy.... (this is just a brief explanation; google some more on nb and how it works to find out more.
You can also check out summer of nhibernate for a great introduction to this ORM) And, to your question: you have a couple of options here: configure you Category property as non-lazy, which will force nbernate to initialize it with the proper object type (much more preferable, in my opinion) do not serialize your Model entities; instead- build some sort of DTO that will hold whatever information your presentation layer needs. This way your presentation needn't be affected by changes to the domain model and vice versa. Also, you can hold all the necessary information in your DTO, even if it's related to more than one Model entity.
For example: public class JokeDTO { public int JokeId; /*more Joke properties*/ public int JokeCategoryId; public string JokeCategoryName; /*etc, etc..*/ }.
Very useful stuff sJhonny. For the moment I won't be going into DTOs, but I shall keep them in mind for future development. Using .Not.LazyLoad() in my fluent nhibernate mapping file worked perfectly to resolve the immediate problem.
Thank you very much. – JLevett Jul 9 at 16:30.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.