entity framework 4 - linq OrderBy property on object -


using ef4 possible orderby property on property, i.e.

entitya has name property. entity b has few other properties , entitya. want list of entityb ordered entitya.name

entityblist = _repo.find<entityb>() .orderby(x => x.entitya.name); 

why doesn't work? know it's not using ef4, concept same.

    using system;     using system.collections.generic;     using system.linq;     using system.text;     using system.threading.tasks;      namespace linqorderbyreference     {         class program         {             static void main(string[] args)             {                 entitya[] entitiesa = {   new entitya { ordinal = 3, secretcode = "xxx"},                                            new entitya { ordinal = 2 ,secretcode = "x"},                                            new entitya { ordinal = 1 ,secretcode = "x"} };                 entityb[] entitiesb = {  new entityb { name = "c", entitya = entitiesa[2] },                                            new entityb {name = "b", entitya = entitiesa[1] },                                           new entityb {name = "a", entitya = entitiesa[0] } };                  ienumerable<entityb> entitiesblist = entitiesb.orderby(x => x.entitya.ordinal);                 foreach (entityb b in entitiesblist)                 {                     console.writeline("entityb.name: {0}, ordinal {1}.", b.name, b.entitya.ordinal);                 }                 console.read();             }         }          public class entitya         {             public int ordinal { get; set; }             public string secretcode { get; set; }         }          public class entityb         {             public string name { get; set; }             public entitya entitya { get; set; }         }     } 

output is:
entityb.name: c, ordinal 1.
entityb.name: b, ordinal 2.
entityb.name: a, ordinal 3.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -