Can anyone help?
I have a linq query which is embedded inside a extension method, it was working as v.RentalStatus was a String. I am now using a Group on my original query (the query is quite complex so i won t put it here).
The importante thing is that v.RentalStatus = IEnumerable hence it can contain things like
A (meaning active)
R (meaning rented)
U (unavailable)
etc - many more
I create a list of what i would like to get back and store this in statusStringList, so for example lets say the list contains A and R
This is my code from before when the v.RentalStatus was just a string, can anyone tell me how i can modify this to work.
var statusStringList = rentalStatus.ToList().ConvertAll<string>(st => st.GetStringValue());
return from v in qry
where statusStringList.Contains(v.RentalStatus)
select v;
If it helps this is part of my query which returns the RentalStatus - its part of a group query but the RentalStatus is not in the group by
RentalStatus= g1.Select( j => j.IdRentalStatus).Distinct(),
g1 is my group by, so if you imagine there are 10 "A", 5 "U" .. then it would return an ienumerable of A and U ... as i am using Distinct. Not 10 As and 5 Us
I hope i have explained it well, please tell me if i haven t
I would appreciate any help from anyone ..
thanks
EDIT
This is my extension signature but not that it matters.
public static IQueryable<Rentals> WithStatus(this IQueryable<Rentals> qry, IList<Contants.Statuses> rentalStatus)
{
EDIT
As mentioned previously when v.RentalStatus was a string it was working but now its IEnumerable - hence a collection.. and it errors with this
Argument 1 : cannot convert from System.Collections.Generic.IEnumerable<string> to string