Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried like below but showing an error like below 'long?' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'long?' could be found (are you missing a using directive or an assembly reference?)

C#
if (CompanyId != null && CompanyId != 0 && CompanyLocationId != null && CompanyLocationId != 0 && ClassID != null && ClassID != 0 && SectionID != null && SectionID != 0)
            {                
                StuList = (from a in (db.Student_Re_Admission.Max(b => b.Re_Admission_Id) 
                           where a.Company_ID == CompanyId && a.COMPANY_LOCATION_ID == CompanyLocationId && a.Class_Id == ClassID && a.Section_Id == SectionID && a.Delete_Flag == false  
                           select new CUSTOM_STU_DETAIL
                           {
                               Re_Admission_Type=a.Re_Admission_Type,
                               Re_Admission_Date=a.Re_Admission_Date,
                               Registration_Id = a.Registration_Id,
                               Admission_No = a.Admission_No,
                               Class_Id = ClassID,
                               Section_Id = SectionID,
                               Academic_Year_Id = a.Academic_Year_Id,
                               Student_First_Name = a.Student_First_Name,
                               Student_Last_Name=a.Student_Last_Name,
                               Date_Of_Birth=a.Date_Of_Birth,
                               Gender=a.Gender,
                               Blood_Group=a.Blood_Group,
                               Cast_Id=a.Cast_Id,
                               Religion_Id=a.Religion_Id,
                               Roll_Id=a.Roll_Id,
                               Set_New_RollNo = a.Set_New_RollNo,
                               Company_ID = CompanyId,
                               COMPANY_LOCATION_ID=CompanyLocationId,
                               STUDENT_NAME = a.Student_First_Name + " " + " " + a.Student_Last_Name,

                               //Attendance_Date = AttDate
                           }).OrderBy(a => a.Admission_No).ToList();
Posted
Comments
Richard MacCutchan 28-Dec-15 6:55am    
So what is your question?
Dawood507 28-Dec-15 6:57am    
first how to get all record on maximum(p.k) base then how to get all rows on condition base of first getted table?
Dawood507 28-Dec-15 7:46am    
I want a query in linq like below..
select * from [Student_Re_Admission] where [Re_Admission_Id] in( SELECT max(Re_Admission_Id) FROM [Student_Re_Admission] group by Registration_Id )

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900