0

I have a custom property (to binding in a Grid) like that :

public class MyClass
{ 
       public virtual IList<clsClass2> MyList{ get; set; }  //Lazy loaded
       public virtual string CustomProperty //To use on Grid Binding
       {
          get
          {
             if (!MyList.IsNullOrEmpty())
                return MyList.Select(__comp => __comp.Name).ToList().ToString(", ");
                return string.Empty;
          }
       }   
}

Its working fine... But that way everytime I load a MyClass object, its load every MyList element because of the CustomProperty...

Is there a better way to do that?

Thanks

1
  • 2
    lazyloaded property whith formula Commented Mar 9, 2012 at 12:22

1 Answer 1

1
 public virtual string CustomProperty //To use on Grid Binding
 {
    get; private set;
 }

// using FLuentMapping
Map(x => x.CustomProperty).Formula("(SELECT ... FROM Class2Table c2 WHERE c2.MyClass_id = Id)");

and exchange ... with your database syntax of aggregating the string see here

Sign up to request clarification or add additional context in comments.

1 Comment

Tried using XML PATH, but got an error... I found that : nhibernate.jira.com/browse/NH-2132 ... So I think I cannot use XML PATH on NHibernate Formula.... Is there any other way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.