开发者

hydrate in nhibernate?

what is hydrate in nhibernate? I am not able to get my head around this term. This was used, i开发者_StackOverflow社区n a video, in context of hydrating the child table rows.

Please advise.

Thanks AJ


You may wish to look at Build Your own DAL. It has a section on hydration that you probably will find interesting.

But hydration from a really simple view means means take from the raw persistent storage module and map into an object/a list of objects.

Update

Look at Understanding Lazy Loading Strategies or Lazy Loading - Eager Loading. I think this is what is happening for the hydration of the objects in the video you describe.

Example

This is a really simple hydration example (Not an NHibernate example)

Say we have run a query like: select name, breed from tblDogs and that has these results

K9, GermanShepard
IBeBlind, Labrador
SmallAnoyance, Shitsu
Trigger, GermanShepard

And say we have the following object:

public class Dog {
  public string name { get; set; }
  public string breed { get; set; }
}

Now we can write our own hydrator:

public List<Dog> Hydrate(results rs) {
   List<Dog> dogs = new List<Dog>();
   foreach(Record rec in rs) {
     Dog d = new Dog();
     d.name = rec["name"];
     d.breed = rec["breed"];
     dogs.Add(d);
   }
  return dogs;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜