Anyone use NHibernate?

  1. #1

    Anyone use NHibernate?

    (Unrelated to Coolite development)

    Hello,

    Anyone on the board use NHibernate? I'm wondering if anyone here has done the following:

    https://forum.hibernate.org/viewtopi...5&t=997570

    If you have any experience doing something similar, I'm trying to avoid using stored procs.0

    Cheers,
    Timothy
  2. #2

    RE: Anyone use NHibernate?

    Hi Timothy,

    If I correctly understood you need a hierarchical table with a field pointing to the id of the same table.
    I think the structure should be:

    Employee

    - ID
    - NAME
    - ROLE
    - PARENT_ID

    don't remember how it works in Nhibernate, but in the entity class I would add a method that retrieves the children items,
    and one retrieving the parent item.

    
    public function List<Employee> GetChildren()
    {
         // return emplyees with parent_id = this.id
    }
    
    public function Employee GetParent(int id)
    
    {
    
         // return emplyee with parent_id = id
    
    }
    
    // it could be:
    
    
    public function ILIst GetChildren()
    {     
           IList employees = sess.CreateCriteria(typeof(Employee))
           .Add(Expression.Eq("ParentId", this.id))    
           .List();
    
    
    return employees;
    }
    I read this: https://www.hibernate.org/hib_docs/n...ycriteria.html

    Then I would build the tree with a recursive function.

    Is it helpfull for you?

    Matteo

Similar Threads

  1. Bind datasource from Nhibernate
    By thesti in forum 1.x Help
    Replies: 0
    Last Post: Apr 08, 2012, 10:44 AM
  2. [CLOSED] Ex.net.json with nhibernate proxies.
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 23, 2012, 2:44 PM
  3. Ex.net.json with nhibernate mapping.
    By endiss in forum 1.x Help
    Replies: 1
    Last Post: Mar 23, 2012, 2:05 PM
  4. Replies: 4
    Last Post: Feb 11, 2010, 4:51 PM
  5. [CLOSED] Gridview datasource with nhibernate
    By jarremw in forum 1.x Help
    Replies: 20
    Last Post: Dec 24, 2008, 2:46 PM

Posting Permissions