Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ORM Generated Entities as Domain Objects for Polymorphism
    primarykey
    data
    text
    <p>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?</p> <p>Note: The code for domain classes are available in <a href="https://stackoverflow.com/questions/11261212/how-to-implement-repository-findall-method">How to Implement Repository FindAll() Method?</a>. Mapping examples is also available there.</p> <p>Note: I am trying to avoid the mapping between Linq 2 SQL generated entities and domain classes.</p> <p><strong>EDIT</strong>: "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."</p> <pre><code>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] </code></pre> <p><img src="https://i.stack.imgur.com/PBi3O.jpg" alt="enter image description here"></p> <p>The factory is as listed below</p> <pre><code>public class MySimpleBankAccountFactory : IBankAccountFactory { public DomainEntitiesForBank.IBankAccount CreateAccount(string accountType, int bankAccountID, string status, System.Nullable&lt;System.DateTime&gt; openedDate, System.Nullable&lt;int&gt; 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; } } </code></pre> <p>READING</p> <ol start="2"> <li><p><a href="https://stackoverflow.com/questions/229627/entity-classes-decoupled-from-linq-to-sql-provider-for-implementing-the-reposito">Entity classes decoupled from LINQ to SQL provider for implementing the Repository pattern. How?</a></p></li> <li><p>Use POCO LINQ to SQL Entities <a href="http://stephenwalther.com/archive/2008/07/22/asp-net-tip-23-use-poco-linq-to-sql-entities.aspx" rel="nofollow noreferrer">http://stephenwalther.com/archive/2008/07/22/asp-net-tip-23-use-poco-linq-to-sql-entities.aspx</a></p></li> <li><p>Using LINQ to SQL XML Mapping Files <a href="http://weblogs.asp.net/dwahlin/archive/2008/08/18/using-linq-to-sql-xml-mapping-files-step-by-step.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/dwahlin/archive/2008/08/18/using-linq-to-sql-xml-mapping-files-step-by-step.aspx</a></p></li> <li><p>How to: Create a Domain Service that uses POCO-defined Entities <a href="http://msdn.microsoft.com/en-us/library/gg602754(v=vs.91).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/gg602754(v=vs.91).aspx</a></p></li> </ol> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload