How do I declare such a variable?
var rData = from nc in ctx.NEWSLETTER_CLIENTS
join ni in ctx.NEWSLETTER_INDICES on nc.INDEX_NUM
equals ni.INDEX_NUM
select new
{
ClientID = nc.CLIENT_ID,
Email = nc.CLIENT_EMAIL_ADDRESS,
Index = nc.INDEX_NUM,
MainClass = ni.MAIN_CLASS,
SubClass = ni.SUB_CLASS,
App1 = ni.VALUE_1,
App2 = ni.VALUE_2,
App3 = ni.VALUE_3,
App4 = ni.VALUE_4
};
// Now I need to declare on a variable named fData under the function scope,
// so I can later use it:
var fData = ...; //What do I declare here?
if(x)
fData = fData.Concat(rData.Where(u => ...));
if(y)
fData = fData.Concat(rData.Where(u => ...));
// etc
If you want to use the query later (iow after the if):
Update:
Now for using with anonymous types:
Update 2:
As pointed out, the above does not actually work, as the predicate of
Wheredoes not know the type. You could refactor it some more to include the predicates in the parameters, example:Update 3: (perhaps hacky)