I Send Iqueryable to a function that is below
void Method<T>(ref IQueryable<T> qu)
{
foreach (T item in qu)
{
}
}
because i need use from tis function for some diffrent Iqueryable
and call this method with
Patient_BusinessEntity Be = new Patient_BusinessEntity();
IQueryable<PatientDataAccess> Query = Be.GetAllRow();
Method<PatientDataAccess> (ref Query);
his work Successfully
now i want use from property of item(variable of loop) in loop
how to can i do this ?
Thanks
IFA
First, is there any reason to make it a
refparameter? If you want to return a new value, using the return value of the method is almost always better than using arefparameter.Now, it’s a generic method – how do you know which property you want to access in the loop? If it’s fixed and you know that T will always be some subtype of something which declares the property, you can just add a constraint:
If you only know it at execution time – or if it’s not declared by any common base type – you’ll have to use reflection to get at it… or you could possibly pass it into the method:
If you could give more information about what you’re trying to do, we may be able to help you more.