Note that there are some explanatory texts on larger screens.

plurals
  1. POPersist Data by Programming Against Interface
    primarykey
    data
    text
    <p>I have a IBankAccount interface that I will be passing to the ApplicationService. The changes made on the account objects (in the ApplicationService project) need to be persisted in the database. The repository receives the changes using IBankAccount interface. How can I persist this data into database? This is implemented using LINQ to SQL.</p> <p>Note: Following is a comment from Scott in <a href="http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx</a> "Add the <strong>interfaces</strong> to your LINQ to SQL data model classes. The LINQ to SQL classes are partial classes - which means you could add the interface directly to them."</p> <pre><code>public class LijosSimpleBankRepository : ILijosBankRepository { public System.Data.Linq.DataContext Context { get; set; } public virtual void UpdateAccount(DomainInterfaces.IBankAccount iBankAcc) { DBML_Project.BankAccount bankAccount; } } namespace DomainInterfaces { public interface IBankAccount { int BankAccountID { get; set; } string AccountType { get; set; } System.Nullable&lt;System.DateTime&gt; OpenedDate { get; set; } string Status { get; set; } System.Nullable&lt;int&gt; AccountOwnerID { get; set; } } } namespace DBML_Project { public class FixedBankAccount : BankAccount { //Note: BankAccount already implemnts IBankAccount } public class SavingsBankAccount : BankAccount { //Note: BankAccount already implemnts IBankAccount } //The auto generated calss is made as abstract [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.BankAccount")] [InheritanceMapping(Code = "Fixed", Type = typeof(FixedBankAccount), IsDefault = true)] [InheritanceMapping(Code = "Savings", Type = typeof(SavingsBankAccount))] public abstract partial class BankAccount : INotifyPropertyChanging, INotifyPropertyChanged, DomainInterfaces.IBankAccount { .. } } </code></pre> <p>READING</p> <ol> <li><p><a href="https://stackoverflow.com/questions/11262785/optimizing-repositorys-submitchanges-method">Optimizing Repository’s SubmitChanges Method</a></p></li> <li><p><a href="https://stackoverflow.com/questions/875130/how-do-you-abstract-out-your-persistence-code-when-using-linq-to-sql/875314#comment14855058_875314">How do you abstract out your persistence code when using LINQ to SQL?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/1021274/linq-to-sql-mapping-exception-when-using-abstract-base-classes">LINQ to SQL - mapping exception when using abstract base classes</a></p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    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