The error message I am getting is:
The type arguments for method ‘System.Linq.Queryable.Contains(System.Linq.IQueryable, TSource)’ cannot be inferred from the usage. Try specifying the type arguments explicitly.
When I run the following code I get an error message saying that I need to explicitly specify the type of argument for method contains.
var result2 = from cltIntake in db.Client_Intakes
where (from cltElig in db.Client_Eligibility_Referrals
where (
from cltDoctVerif in db.Doct_Verifications
where cltDoctVerif.Verification_Status == "Yes"
select cltElig.Asgnd_Caseworker_ID == 6
).Contains(cltElig.Client_Eligibility_ID)
select new { client_Eligibility_ID = cltElig.Client_Eligibility_ID }
).Contains(cltIntake.Client_Intake_ID)
select new
{
cltInfo.First_Name,
cltInfo.Last_Name,
};
I have looked around a lot and tried to cast to type int, since the collection is type int, as follows
.Contains<Int32>(cltElig.Client_Eligibility_ID)
but that threw an error saying:
Instance argument: cannot convert from ‘System.Linq.IQueryable’ to ‘System.Linq.IQueryable’
Instance argument: cannot convert from ‘System.Linq.IQueryable’ to ‘System.Linq.IQueryable’
I really appreciate if someone gives me a solution for this. The thing is I don’t really know much about IQueryable.
Thank you
The problem is that your selection is creating a sequence of anonymous types, but your call to Contains is passed a Int
So rather than
select new { client_Eligibility_ID = cltElig.Client_Eligibility_ID }just doselect cltElig.Client_Eligibility_IDadditionally you haveselect cltElig.Asgnd_Caseworker_ID == 6' which is projecting a boolean. You probably wanted&& cltElig.Asgnd_Caseworker_ID == 6`Additionally, consider simplifying the query