Order by marker of Inheritance - Table-per-Hierarchy RRS feed

  • Question

  • Hello,
    I have table called File with a few columns. One of the columns called Type is used in EF as class type distinguisher.
    So for class FileA Type = 0, for class FileB Type = 1 and so on as in Inheritance - Table-per-Hierarchy.
    Moreover my another entity called Directory has a property



    global::System.Data.Objects.DataClasses.EntityCollection<File> Files

    and I would like to load objects from database in order specified by Type. I can not use it with use of linq OrderBy in this fashion Files.OrderBy(e=>e.Type) becouse Type does not exist as a field in entity File.
    I would prefer to load my files from the context of the Directory and not via ObjectContext class.

    How can I achieve this? Is is possible?

    Sunday, November 1, 2009 8:33 PM


  • Have you considered ordering them at client side, once you got them?

    files.ToList().OrderBy(e=> (e is XXX) ? 1 : 2); 
    Please mark posts as answers/helpful if it answers your question
    • Marked as answer by Yichun_Feng Sunday, November 8, 2009 2:04 AM
    Sunday, November 1, 2009 10:19 PM