Note that there are some explanatory texts on larger screens.

plurals
  1. POReposity pattern using linq
    primarykey
    data
    text
    <p>How can I implement the so called "repository pattern" that Rob Conery shows in [MVC Storefront][1] when I use two different generated linq codes? Do I need to implement a real repository pattern as Fredrik Normen discusses at <a href="http://weblogs.asp.net/fredriknormen/archive/2008/04/24/what-purpose-does-the-repository-pattern-have.aspx" rel="nofollow noreferrer">What purpose does the Repository Pattern have?</a>? The thing is that I want pass some of the nice features that LINQ provides from my "repository" so that I can use it later, so if not required I do not want to implement a real repository pattern as Fredrik discussed about.</p> <p>Now to my problem. I have downloaded [dblinq ][3] which is a Linq Provider for MySql, Oracle and PostgreSQL. In my project I have now generated LINQ code for MySQL and SQL(microsoft). The problem is that they both need to generate classes with same names but with somewhat different content. Can I use somehow implement this with namespaces or something so that I can be able to use them both, as is the idea with the "repository pattern"? Example for a Language table SQl</p> <pre><code>[Table(Name="dbo.Language")] public partial class Language : INotifyPropertyChanging, INotifyPropertyChanged { private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); private int _Id; private string _Name; private EntitySet&lt;Book&gt; _Books; #region Extensibility Method Definitions partial void OnLoaded(); partial void OnValidate(System.Data.Linq.ChangeAction action); partial void OnCreated(); partial void OnIdChanging(int value); partial void OnIdChanged(); partial void OnNameChanging(string value); partial void OnNameChanged(); #endregion public Language() { this._Books = new EntitySet&lt;Book&gt;(new Action&lt;Book&gt;(this.attach_Books), new Action&lt;Book&gt;(this.detach_Books)); OnCreated(); } [Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] public int Id { get { return this._Id; } set { if ((this._Id != value)) { this.OnIdChanging(value); this.SendPropertyChanging(); this._Id = value; this.SendPropertyChanged("Id"); this.OnIdChanged(); } } } [Column(Storage="_Name", DbType="NVarChar(100) NOT NULL", CanBeNull=false)] public string Name { get { return this._Name; } set { if ((this._Name != value)) { this.OnNameChanging(value); this.SendPropertyChanging(); this._Name = value; this.SendPropertyChanged("Name"); this.OnNameChanged(); } } } [Association(Name="Language_Book", Storage="_Books", ThisKey="Id", OtherKey="Language")] public EntitySet&lt;Book&gt; Books { get { return this._Books; } set { this._Books.Assign(value); } } public event PropertyChangingEventHandler PropertyChanging; public event PropertyChangedEventHandler PropertyChanged; protected virtual void SendPropertyChanging() { if ((this.PropertyChanging != null)) { this.PropertyChanging(this, emptyChangingEventArgs); } } protected virtual void SendPropertyChanged(String propertyName) { if ((this.PropertyChanged != null)) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } private void attach_Books(Book entity) { this.SendPropertyChanging(); entity.Language1 = this; } private void detach_Books(Book entity) { this.SendPropertyChanging(); entity.Language1 = null; } } </code></pre> <p>MySQL</p> <pre><code> [Table(Name = "asp.Language")] public partial class Language : INotifyPropertyChanged { #region INotifyPropertyChanged handling public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion #region int ID private int _id; [DebuggerNonUserCode] [Column(Storage = "_id", Name = "Id", DbType = "int", IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false)] public int ID { get { return _id; } set { if (value != _id) { _id = value; OnPropertyChanged("ID"); } } } #endregion #region string Name private string _name; [DebuggerNonUserCode] [Column(Storage = "_name", Name = "Name", DbType = "varchar(100)", CanBeNull = false)] public string Name { get { return _name; } set { if (value != _name) { _name = value; OnPropertyChanged("Name"); } } } #endregion #region Children private EntitySet&lt;Book&gt; _book; [Association(Storage = "_book", OtherKey = "Language", ThisKey = "ID", Name = "Book_ibfk_1")] [DebuggerNonUserCode] public EntitySet&lt;Book&gt; Book { get { return _book; } set { _book = value; } } #endregion #region Attachement handlers private void Book_Attach(Book entity) { entity.LanguageLanguage = this; } private void Book_Detach(Book entity) { entity.LanguageLanguage = null; } #endregion #region ctor public Language() { _book = new EntitySet&lt;Book&gt;(Book_Attach, Book_Detach); } #endregion } </code></pre>
    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.
    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