Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7614375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:23:18+00:00 2026-05-31T02:23:18+00:00

I´m trying to use QueryOver in that scenario : public class Class1 { public

  • 0

I´m trying to use QueryOver in that scenario :

public class Class1
{
    public virtual string Name { get; set; }
    public virtual string Descripton { get; set; }
    public virtual Class2 { get; set; }
    public virtual IList<Class3> ListClass3{ get; set; }
    ... //SEVERAL OTHERS LISTS, PROPERTIES
}

 public class Class2
{
    public virtual string Name { get; set; }
    ... //SEVERAL OTHERS LISTS, PROPERTIES
}


public class Class3
{
    public virtual string Name { get; set; }
    public virtual Class4 { get; set; }
    ... //SEVERAL OTHERS LISTS, PROPERTIES
}

public class Class4
{
    public virtual string Prop1 { get; set; }
    public virtual string Prop2{ get; set; }
    ... //SEVERAL OTHERS LISTS, PROPERTIES
}

And my DTO :

public class ClassDTO
{
    public string NameClass1 { get; set; }
    public string DescriptonClass1 { get; set; }
    public string NameClass2 { get; set; }

    public virtual IList<Class3> Class3List { get; set; }       
}

My problem is how get the IList … Without that, thats working fine so far:

Class2 class2 = null;
IList<Class3> listClass3 = null;
var queryOver = Session.QueryOver<clsClass1>();

var list =  queryOver
            .JoinAlias(x => x.Class2, () => class2)
            .JoinAlias(x => x.ListClass3, () => listClass3, JoinType.LeftOuterJoin)
            .SelectList(list => list                
              .Select(c2 => c2.Name).WithAlias(() => myDTO.NameClass1)
              .Select(c2 => class2.Name).WithAlias(() => myDTO.NameClass2)
              //NEED GET LIST<CLASS3>
             )
       .TransformUsing(Transformers.AliasToBean<ClassDTO>())
            .List<ClassDTO>();

Thats working fine, but I need to ‘fill’ the IList now… And if possible, get just the Prop1 and Prop2 from Class4…

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:23:21+00:00Added an answer on May 31, 2026 at 2:23 am

    something that is close to what you want taking one roundtrip

    // get ClassDTOs
    Class2 class2 = null;
    ClassDTO myDTO = null;
    var results = Session.QueryOver<Class1>()
        .JoinAlias(x => x.Class2, () => class2)
        .SelectList(list => list                
            .Select(c1 => c1.Id).WithAlias(() => myDTO.IdClass1)
            .Select(c1 => c1.Name).WithAlias(() => myDTO.NameClass1)
            .Select(c1 => c1.Description).WithAlias(() => myDTO.DescriptionClass1)
            .Select(() => class2.Name).WithAlias(() => myDTO.NameClass2)
        )
        .TransformUsing(Transformers.AliasToBean<ClassDTO>())
        .Future<ClassDTO>();
    
    // get Class3DTOs
    Class3 class3 = null;
    Class3DTO myClass3DTO = null;
    var subresults = Session.QueryOver<Class1>()
        .JoinAlias(x => x.Class3List , () => class3)
        .JoinAlias(() => classe3.Class4 , () => class4)
        .SelectList(list => list                
            .Select(c => c.Id)
            .Select(() => class3.Name)
            .Select(() => class4.Prop1)
            .Select(() => class4.Prop2))
        .Future<object[]>()
        .ToLookup(array => (int)array[0], array => new myClass3DTO
        {
            NameClass3 = (string)array[1],
            Prop1Class4 = (string)array[2],
            Prop2Class4 = (string)array[3],
        });
    
    // assigne the lists to the dto
    foreach (var result in results)
    {
        result.ListClass3 = subresults[result.IdClass1].ToList();
    }
    
    return results;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying use a set of filter functions to run the appropriate routine,
Trying to use an excpetion class which could provide location reference for XML parsing,
I am trying use filehelpers class builder but I am kinda confused on what
I'm trying use the Str[fixnum] to return a specific portion of a string. #
I'm trying use eco for client-side templating. I have multiple .eco templates that I'd
public class db { public static string connectionString = WebConfigurationManager.ConnectionStrings[connectString].ConnectionString; public static SqlConnection OpenConnection()
I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
I'm trying use preg_match in an IF statement and return false if a string
I am trying use the jQuery table sorter plugin for a table that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.