tags:

views:

487

answers:

1

I have a List of type Fee from which I need to exclude the ones that have an ID that exists in another List of type int.

List<int> ExcludedFeeIDs = new List<int>{1,2,3,4};

List<Fee> MyFees = (from c in ctx.Fees
                    select c).ToList();

Example: List GoodFees = (from f in ctx.Fees where f.FeeID!=One of the IDs in ExcludedFeeIDs);

Help please?

+4  A: 

Try this:

var MyFees = from c in ctx.Fees
             where !ExcludedFeeIDs.Contains(c.FeeID)
             select c;
Yannick M.
Worked like a charm! Thanks Yannick.
Ozzie Perez
Glad I can help.
Yannick M.
For simply queries some people prefer using the dot notation: var myFees = ctx.Fees.Where(fee => !ExcludedFeeIDs.Contains(fee.FeeID));
ICR
Yea.. that way's cool too. Thanks ICR
Ozzie Perez