Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 26th, 2012  |  syntax: None  |  size: 1.08 KB  |  views: 78  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Fluent Nhibernate inner join
  2. Master
  3. public virtual int Id { get; private set; }
  4. public virtual Imagen imagen { get; set; }
  5.  
  6. Imagen
  7. public virtual int Id { get; private set; }
  8. public virtual Linea linea { get; set; }
  9.  
  10. Linea
  11. public virtual int Id { get; private set; }
  12. public virtual String Nombre { get; set; }
  13.        
  14. SELECT * FROM dbo.Master
  15. INNER JOIN dbo.Imagen ON dbo.Master.imagen_id = dbo.Imagen.Id
  16. INNER JOIN dbo.Linea ON dbo.Imagen.linea_id = dbo.Linea.Id
  17. WHERE dbo.Linea_Id = 5
  18.        
  19. ICriteria c = session.CreateCriteria(typeof(Master))
  20.   .CreateAlias("dbo.Imagen", "img", JoinType.InnerJoin)
  21.   .Add(Restrictions.Eq("img.linea_id", id_linea));
  22.  
  23. return c.List<Master>();
  24.        
  25. var list = session.QueryOver<Master>()
  26.                         .JoinQueryOver(master => master.imagen)
  27.                         .Where(imagen => imagen.linea.Id == 5)
  28.                         .List();
  29.        
  30. ICriteria c = session.CreateCriteria(typeof(Master))
  31.  
  32. .CreateAlias("imagen", "img", JoinType.InnerJoin)
  33. .CreateAlias("img.linea", "lin", JoinType.InnerJoin)
  34. .Add(Restrictions.Eq("lin.Id", 5));
  35.  
  36. return c.List<Master>();
clone this paste RAW Paste Data