I have the following code.
MyDataContext db = MyDataContext.Create();
bc =
db.BenefitCodes.Select(
b =>
new
{
BenCd = b.BenCd
, Description = b.BenDesc
, BenInterest = b.BenInterest
, CodeDescription = string.Format("{0} - {1}", b.BenCd, b.BenDesc)
});
I had to go the Anonymous type route as CodeDescription isn't a property of benefitCode and the customer wants it to appear this way in a dropDrownList. Anyways my question is how can I select a subset of items from this list? I need to select items based on the BenInterest attribute.
So this returns IEnumerable, so I am trying to go this route and this is where I get stuck. My intent is to build a new IEnumerable list and set a dropdown datasource to it.
IEnumerator enumerator = BenefitCodes.GetEnumerator();
while(enumerator.MoveNext())
{
//What can I do here to return items based on BenInterest?
//I basically either want items that have a BenInterest of 'E'
// or items that DO NOT have a BenInterest of 'E'
// this is based on the value of a radioButtonList on the page
}
So how do I create a new Enumerable of the same Anonymous type that only contains the desired items.
Thanks for any help. Cheers, ~ck