linq query to display records in order of year and month -
i having following table:
salary table: salaryid,empid,basic,monthid,yearid,net salary
year table: yearid,yearname.(yearname 2013,2014...)
month table: monthid,monthname.(monthname jan,feb...)
emp_master: empid,empname
i having following records in gridview fetching directly table without condition.
my table contain following records shown below:
empname netsalary month year
abc 4000 dec 2013
xyz 4000 dec 2013
abc 4000 feb 2014
xyz 4000 feb 2014
abc 5000 mar 2014
xyz 5000 mar 2014
now want display records in order of month , year first should display records of highest month march , feb.
i want output this:
empname netsalary month year
abc 5000 mar 2014
xyz 5000 mar 2014
abc 4000 feb 2014
xyz 4000 feb 2014
abc 4000 dec 2013
xyz 4000 dec 2013
i have written query displaying records in tables.
var data = (from s in context.salary_masters select new {name = s.emp_master.empname, s.net_pay, mnth=s.month_master.month_name, year=s.year_master.year_name });
here{name,mnth , year used anonomous type in query name of datatextfield of gridview.}
can edit linq query suit needs ????
please please please me.i new linq dont know how write query.
try (not test make on fly)
var data = (from s in context.salary_masters select new {name = s.emp_master.empname,s.net_pay,mnth=s.month_master.month_name,year=s.year_master.year_name }).orderby(z=> z.mnth,z.year);
Comments
Post a Comment