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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:42:25+00:00 2026-05-26T02:42:25+00:00

I have the following setup for a simple application: generated LINQ to SQL classes

  • 0

I have the following setup for a simple application:

  1. generated LINQ to SQL classes from my database tables (DAL?)

  2. created classes (BLL?) that use the LINQ to SQL datacontext, to insert, update, delete, select

  3. in my presentation layer, when inserting e.g. a new "product", I’m creating a new instance of object "Product", which comes from my DAL layer (this is what LINQ to SQL created for me)

My question is if this is the right way to go for separation of layers in this case. What’s strange to me is that I’m using an object type that was defined in the DAL, which shouldn’t be used in the presentation layer if you ask me. But if I want to make use of the LINQ to SQL objects without again creating new objects, this seemed like the way to go.

What’s your advice on this? I’m not sure what’s the best way to go about here.

  • 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-26T02:42:26+00:00Added an answer on May 26, 2026 at 2:42 am

    I don’t think there is ever a one-size-fits-all solution, but, if you have a simple application, you probably don’t want to complicate things unnecessarily
    If you are able to stomach keeping the data context open at your presentation tier, there are some ‘productivity’ gains in keeping the L2SQL entities:

    • Support for lazy loading (although watch out for the 1:N problem)
    • You have a single set of generated entities (albeit datacontext aware)

    However, for a heavier, more purist architecture, you could consider

    • Wrapping the Linq2SQL artifacts in a Repository Pattern
    • Map out the L2SQL entities into POCOs before returning them to your BLL / Service Tier
    • Depending on your network and presentation architectures, you may also need to consider what you entity looks like over the network (Serialization, WCF, JSON etc) and you might also look at View Models, in which case your entity will ‘change’ class and shape several times as it is mapped and transformed between layers.
    • In fact, you might consider another ORM than Linq2SQL entirely, e.g. NH or EF

    EDIT:
    You’ve got a couple of options if you don’t want to work with the VS generated L2SQL entities in your BLL or Presentation Layer.

    • Create a new set of POCOs and then map the L2SQL entities out in your repository / dal. Automapper can simplify this task.

    • You can use your own POCOs directly in Linq2SQL, by providing an XmlMappingSource, although this is a bit more work.

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

Sidebar

Related Questions

I have the following setup: Code on my local machine (OS X) shared as
How do you setup a multi-developer XDebug PHP environment? I have the following setup:
I have following situation. A main table and many other tables linked together with
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following text in a file 23456789 When I tried to replace the
I have following Code Block Which I tried to optimize in the Optimized section

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.