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 396037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:30:45+00:00 2026-05-12T16:30:45+00:00

I just started playing with Linq to SQL the other day and was curious

  • 0

I just started playing with Linq to SQL the other day and was curious if I should use it in up coming projects. I know it will save me tons of development time. I have seen many similar questions out there on the subject but I have a few more specific questions.

  • Is there anything wrong with inheriting the classes generated in the .dbml file?

  • Are the generated SQL commands efficient? When I used SQL Server Profiler I noticed when I would get a list of all records using a linqDataSource to bind to a gridView I would see two queries being executed. The first one was a

    SELECT COUNT(*) and then a SELECT TOP(PageSizeOfGrid).  
    

    Why?

  • Would I be better off using an ObjectDataSource getting all records from a stored procedure and caching them?

  • Entity Framework? Don’t know much about it but I think it may be too heavy for my needs. Most of my databases are fairly simple 10 – 20 tables that may have many to many relationships. Is it worth looking into?

Any ideas on any of this are appreciated. Thanks!

  • 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-12T16:30:46+00:00Added an answer on May 12, 2026 at 4:30 pm

    Is there anything wrong with
    inheriting the classes generated in
    the .dbml file?

    No, nothing wrong. And likewise, you can make the generated classes inherit from your own base classes or implement other interfaces than the out-of-the-box ones.

    Are the generated SQL commands
    efficient?

    Yes, but as always you need to keep an eye on it. If you write your linq queries the same was as good SQL queries the generated sql will be very efficient. L2S is pretty good at optimizing under some scenarios, e.g. it eliminates anything that can be eliminated on the client etc. That said, it is possible to make it generate bad SQL just like it is possible to write inefficient raw SQL queries by hand. Click here for an example …

    When I used SQL Server Profiler I
    noticed when I would get a list of all
    records using a linqDataSource to bind
    to a gridView I would see two queries
    being executed. The first one was a
    SELECT COUNT(*) and then a SELECT
    TOP(PageSizeOfGrid). Why?

    No idea, never used the LinqDataSource. I prefer to go with raw linq queries, I’m not a fan of automated data source controls/objects. Hopefully someone else can shed some light on that one.

    Would I be better off using an
    ObjectDataSource getting all records
    from a stored procedure and caching
    them?

    Same as previous… 🙂

    Entity Framework? Don’t know much
    about it but I think it may be too
    heavy for my needs. Most of my
    databases are fairly simple 10 – 20
    tables that may have many to many
    relationships. Is it worth looking
    into?

    Wait until next version of EF. It will be released as part of .net 4.0. The current version of EF is not ready for prime-time and for some odd reason Microsoft decided to not patch the base problems but instead put all their time and energy into working on 4.0. Whether that one will be a worthy competitor/replacement for L2S remains to be seen. (I have only tried beta 1, and that one suffers from the same issues as EFv1; primarily problems with poor generated SQL queries… (ex 1 ex 2 ex 3 etc)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(please excuse that I didn't use aliases). I would like my query output to
I am playing with TFS 2010, and am trying to setup a build process
My question is about memory use and objects in actionscript 2. If I have
I'm working on a project in C# w/ XNA, and I want to reorganize
I have a new web app that is packaged as a WAR as part
There doesn't seem to be any tried and true set of best practices to
I am using a 3rd-party rotator object, which is providing a smooth, random rotation

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.