Hi
How to initialize Result variable
Result = (from t2 in context.View_SessionDeliveryCalendarDetails_Students
where t2.MentorID == mentorId
select new { t2.StudentID, Name = t2.Name + " - " + t2.MobileNo }).Distinct().ToList();
Thanks
Jignesh KumarPosted Apr 7, 2023, 3:46 AM
Hello Ramco,
you can create one class with same property you want use in select statement, for above you can create,
You can initialize as below
Then in UI/ Cshtml filr you can do string concate using Name + MobileNumber
Rajkiran SwainPosted Apr 6, 2023, 2:17 PM
the type of Result in this case is an anonymous type, as it is created using the
new { }syntax in theselectstatement. The properties of this anonymous type areStudentIDandName.Ramco RamcoPosted Apr 6, 2023, 2:08 PM
Hi Rajkiran
What should be type of Result . How it should be initialized.
Thanks
Rajkiran SwainPosted Apr 6, 2023, 1:57 PM
The error "cannot convert from 'System.Collections.Generic.List' to 'System.Collections.Generic.List'" is caused by a mismatch between the type of the result of your query and the type of the variable you are trying to assign it to.
Rajkiran SwainPosted Apr 6, 2023, 1:57 PM
you need to create a new instance of the "StudentsBreak" class for each item in your LINQ query result and add it to a new list of type "List" . You can use a foreach loop to iterate over the items in the query result and create new instances of the "StudentsBreak" class for each item, like this:
In this code, you would replace "queryResult" with your LINQ query result, and "StudentsBreak" with the name of your class that has the "StudentID" and "Name" properties. This will create a new list of "StudentsBreak" objects with the data from your query result.
Ramco RamcoPosted Apr 6, 2023, 1:45 PM
Hi Rajkiran
I am getting error cannot convert from system.collection.generic to system.collection.dynamic.
Thanks
Rajkiran SwainPosted Apr 6, 2023, 1:33 PM