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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:09:07+00:00 2026-06-06T21:09:07+00:00

We need following domain class model to be generated from the table listed below.

  • 0

We need following domain class model to be generated from the table listed below. Is it possible to achieve it using Linq 2 SQL. If it is not possible, will Entity Framework help? Can you please explain how to do it?

Note: The code for domain classes are available in How to Implement Repository FindAll() Method?. Mapping examples is also available there.

Note: I am trying to avoid the mapping between Linq 2 SQL generated entities and domain classes.

EDIT: “Linq to SQL, as an Object Relational Mapping technology, supports only the Table per Class Hierarchy strategy. This means that all levels in the inheritance hierarchy are stored in the same table, and a discriminator column tells what class a record represents.”

CREATE TABLE [dbo].[BankAccount](
[BankAccountID] [int] NOT NULL,
[AccountType] [nchar](10) NOT NULL,
[OpenedDate] [datetime] NULL,
[Status] [nchar](10) NULL,
[AccountOwnerID] [int] NULL,
 CONSTRAINT [PK_BankAccount] PRIMARY KEY CLUSTERED 
(
[BankAccountID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,
 ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

enter image description here

The factory is as listed below

public class MySimpleBankAccountFactory : IBankAccountFactory
{
    public DomainEntitiesForBank.IBankAccount CreateAccount(string accountType, int bankAccountID, string status, System.Nullable<System.DateTime> openedDate, System.Nullable<int> accountOwnerID)
    {
        DomainEntitiesForBank.IBankAccount acc = null;

        if (System.String.Equals(accountType, "Fixed"))
        {
            acc = new DomainEntitiesForBank.FixedBankAccount();
            acc.BankAccountID = bankAccountID;
            acc.AccountStatus = status;
        }

        if (System.String.Equals(accountType, "Savings"))
        {
            acc = new DomainEntitiesForBank.SavingsBankAccount();
            acc.BankAccountID = bankAccountID;
            acc.AccountStatus = status;
        }

        return acc;
    }
}

READING

  1. Entity classes decoupled from LINQ to SQL provider for implementing the Repository pattern. How?

  2. Use POCO LINQ to SQL Entities
    http://stephenwalther.com/archive/2008/07/22/asp-net-tip-23-use-poco-linq-to-sql-entities.aspx

  3. Using LINQ to SQL XML Mapping Files
    http://weblogs.asp.net/dwahlin/archive/2008/08/18/using-linq-to-sql-xml-mapping-files-step-by-step.aspx

  4. How to: Create a Domain Service that uses POCO-defined Entities
    http://msdn.microsoft.com/en-us/library/gg602754(v=vs.91).aspx


  • 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-06T21:09:08+00:00Added an answer on June 6, 2026 at 9:09 pm

    I’m not sure if Linq-to-Sql supports mapping to interfaces (Entity framework does not but NHibernate does). If you replace your IBankAccount with abstract class BankAccount you should be able to simply map TPH inheritance in all mentioned technologies. Here is example for Linq-to-Sql.

    Once you have mapped inheritance you can query either a base class or specific class (by using OfType in Linq-to-Sql or Entity Framework). When querying a base class ORM will internally goes through all inherited classes as well.

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

Sidebar

Related Questions

My Entity Framework model is generated from SQL Server database. Since I need to
What do you think of the following table mapping style for domain entities? class
I need to rewrite an image path on the following URLs: domain.com/system/index domain.com/system/view/12345 domain.com/system/search/term1:/term2:data/term3:/term4:data/term5
I need a .htaccess configuration that does the following: Redirect www.domain.com to domain.com Redirect
I need to do a url rewrite maintaining following condition: rewrite http://domain.net (or http://www.domain.net
I need following function (from C++ dll) available in C++/CLI extern C _declspec(dllexport) void
I would like to delete the ICollection PriceBreaks from Product. I'm using the following
Suppose I have the following Domain class: class Book { String title String author
I've got the following structure set up in ActiveRecord in Rails 3 class Domain
I have the following DB model: **Person table** ID | Name | StateId ------------------------------

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.