Require Subquer

Thiyagarajan's Avatar

Thiyagarajan

16 Mar, 2010 02:43 PM via web

I have a table evaluation which has fields like text, create_user,create_time and update_user, My current requirement is that I need to get the first name and last name of create_user from the person table and create_user is not a primary key in person table. Person table field are id (pk), login, password, firstname and last name. Create_user should be mapped with login and fetch the first name and last name. I am looking for a code snippet to write the query to fetch the firstname and last name.

  1. Support Staff 2 Posted by James Gregory on 17 Mar, 2010 11:36 AM

    James Gregory's Avatar

    I'm going to need you to explain your problem a little clearer if you want me to help. Please show me your schema, any mappings you have, and what you've tried so far.

  2. 3 Posted by Thiyagarajan on 17 Mar, 2010 01:21 PM

    Thiyagarajan's Avatar

    I have pasted the code snippet below
    WithTable("elevevaluering");

    Id(x => x.Id, "elevevaluering_id")
    .GeneratedBy .Native();

    Map(x => x.Text).ColumnName("evaluering");
    Map(x => x.InternNote).CustomTypeIs().ColumnNames.Add("intern_note");
    Map(x => x.CreateTime).ColumnName("create_time");
    Map(x => x.CreateUser).ColumnName("create_user");
    Map(x => x.UpdateTime).ColumnName("update_time");
    Map(x => x.UpdateUser).ColumnName("update_user");

    References(x => x.Skole).ColumnName("skole_fk");
    References(x => x.UdbudtLæringsaktivitet).ColumnName("udbudt_lakt_fk");
    References(x => x.UdbudtLæringselement).ColumnName("udbudt_lelem_fk");
    References(x => x.Person).ColumnName("person_fk");
    References(x => x.UvmFag).ColumnName("uvmfag_fk");

       HasMany(x => x.ElevevalueringLæstAf)
       .KeyColumnNames.Add("elevevaluering_fk")
       .Cascade.AllDeleteOrphan()
        .Inverse()
         .AsSet();
    

    As I explained in my earlier post, I need to get the firstname and last name of create_user from person table.

  3. Support Staff 4 Posted by James Gregory on 17 Mar, 2010 01:24 PM

    James Gregory's Avatar

    What's create_user? A string? How is it associate with the Person table?

    If you show me your entities, I'll be able to understand better.

  4. 5 Posted by Thiyagarajan on 18 Mar, 2010 05:06 AM

    Thiyagarajan 's Avatar

    create_user (string type) in elevevaluering table relates with the brugerlogin( not a primary key, string type) in person table and find the attachment for E/R diagram that will give you information about the entities.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is 14 minus 4?