Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:34:27+00:00 2026-06-05T06:34:27+00:00

How do I declare such a variable? var rData = from nc in ctx.NEWSLETTER_CLIENTS

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:34:29+00:00Added an answer on June 5, 2026 at 6:34 am
    IQueryable<type of p> fData = null;
    

    If you want to use the query later (iow after the if):

    var fData = Enumerable.Empty<type of p>().AsQueryable();
    

    Update:

    Now for using with anonymous types:

    IQueryable<T> RestOfMethod<T>(IQueryable<T> rData)
    {
      var fData = Enumerable.Empty<T>().AsQueryable(); // or = rData;
    
      if(x)
        fData = fData.Concat(rData.Where(u => ...));
      if(y)
        fData = fData.Concat(rData.Where(u => ...));
    
      return fData;
    }
    
    // original code location
    var rData = some query;
    var fData = RestOfMethod(rData);
    

    Update 2:

    As pointed out, the above does not actually work, as the predicate of Where does not know the type. You could refactor it some more to include the predicates in the parameters, example:

    IQueryable<T> RestOfMethod<T>(IQueryable<T> rData, 
      Expression<Func<T,bool>> pred1,
      Expression<Func<T,bool>> pred2) 
    { ... }
    

    Update 3: (perhaps hacky)

    var fData = rData.Take(0); // should be cheap. 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

declare fName varchar2(255 char); begin SELECT x.constraint_name into fName FROM all_constraints x JOIN all_cons_columns
I want to declare a local variable as such: (var n=1) Mostly so I
I'm declaring a varchar variable in T-SQL declare @var varchar(max); I have a select
declare @i int declare @skool float declare schoolCursor cursor for select distinct choice from
I have a LINQ query such as: using(csv.......) { csv.Select(x => new Data() {
I have two files, in one I declare the variable SEED as such: ;file1.asm
I often have similar constructions: var t = from i in Enumerable.Range(0,5) select num(i);
I want to declare a variable in such a way that I can access
I wish to declare a variable in such a way as it can be
If I want to declare a newtype such that type type of the value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.