1

I am using entity framework to develop asp.net website(C#) with SQL database I have column[FromMonth] saving string data Type (not int), how to add order by with that sort order
{ Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec } descending please help

 List< TblExperince > experince =(from x in db.TblExperince
                           where x.id_main == IDmain
                           orderby x.FromYear descending[,x.FromMonth ??]
                             select x).ToList();

I found the solution by adding new table to my .edmx model for ordering months and its work

  List<TblExperince> experince = (from x in db.TblExperince
                                  join o in db.TblMonthOrder  on x.FromMonth  equals o.MonthName 
                                  where x.id_main == IDmain
                                  orderby x.FromYear descending,o.MonthNo descending 
                                  select x).ToList();
May T.
  • 11
  • 2
  • More headache than it's probably worth! Store month name and value in another table and then order it by that value. – Ric Apr 05 '17 at 10:58
  • Actually I already used related table in my work but it's my first time using entity framework and I wont to get familiar with it , I found the solution by adding new table to my .edmx model and its work , thanks for hint – May T. Apr 10 '17 at 08:59

0 Answers0