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

  • SEARCH
  • Home
  • 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 208779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:51:23+00:00 2026-05-11T17:51:23+00:00

EDIT 1 I apologize but after reading the 2 suggested articles I still don’t

  • 0

EDIT 1

I apologize but after reading the 2 suggested articles I still don’t understand what I should use. I understand that using IQueryable is not preferred for various reasons but does that eliminate IEnumerable as well? Is a DataTable really my best option?

In short, I guess, what is the preferred Return type?


I have the following simple LINQ query that I want to abstract out into a DAL. What is the type of var and therefore what type should my method be?

            ConnectDBDataContext context = new ConnectDBDataContext();

        var lName = textEdit1.Text;

        var searchByPersonLName = from c in context.tblPersons
                                  where c.LastName == lName
                                  orderby c.LastName
                                  select new { c.FirstName,c.LastName,c.PersonID};

        dataGridView1.DataSource = searchByPersonLName;

When I hover over it in VS it says IQueryable<T> but when I put in a breakpoint and run it it seems to call itself IEnumerable. Which is correct and how should I declare my method?

Like this –>

        public static DataTable SearchPerson(string SearhParam)
    {
        ConnectDBDataContext context = new ConnectDBDataContext();
        var persons = (from person in context.tblPersons
                       orderby person.LastName
                       select new { person.PersonID, person.LastName, person.FirstName, person.SSN });
        var filteredPersonsList = persons.Where(p => p.LastName == SearhParam).ToList();
        if (filteredPersonsList.Count == 0)
            filteredPersonsList = persons.Where(p => p.LastName.StartsWith(SearhParam)).ToList();

        var dataTable = filteredPersonsList.CopyLinqToDataTable();

        return dataTable;
    }

If I use IQueryable<T> what is <T> or how do I know that and what would I return?

Thanks!

For Reference the CopyToDataTable() is below.

public static DataTable CopyLinqToDataTable<T>(this IEnumerable<T> source)
    {
        return new ObjectShredder<T>().Shred(source, null, null);
    }

    public static DataTable CopyLinqToDataTable<T>(this IEnumerable<T> source,
                                                DataTable table, LoadOption? options)
    {
        return new ObjectShredder<T>().Shred(source, table, options);
    }
  • 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-05-11T17:51:23+00:00Added an answer on May 11, 2026 at 5:51 pm

    What he means is to map your data to the object you are wanting the DAL to return.

    In answer to your first question “var” is really just short for variable, and the type is what ever type is defined in the assignment.

    var myvariable = string.empty;
    

    In this example the type is that of a string.

    var myreader = new StringReader();
    

    While in this example the type is that of a StringReader.

    As for your second question of “what is “. T is a generic type.

    For an example of where your dal would be returning an actual object:

     public Product GetProduct(int ProductID)
        {
            var product = from p in db.MyTable
                          where p.productID == ProductID
                          select new product { name = p.name, pricepoint = p.pricepoint, qty = p.quantity };
    
            return product;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I apologize if this is a duplicate but I did not find anything that
EDIT: damien the unbeliever, my apologies, trying to be terse I omitted saying that
Edit: Translated I have a RSS-feed that i want to parse. It's a podcast
I understand that this question has been done to death so I'll apologise in
Apologies for reposting but I had to edit this question when I got to
I apologize for the title, but I couldn't think of a better way to
It seems that the choice to use string parsing vs. regular expressions comes up
If this has been asked before, I apologize but this is kinda of a
Apologies for posting such long, non-compilable code. But despite reading several questions and answers
I'm able to make the method for the call [self weaponAttachments:mpk5] but I don't

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.