从LinqToSQL转换为Linq2DB

huangapple go评论64阅读模式
英文:

Convert from LinqToSQL to Linq2DB

问题

我有一个项目,其中已经创建了一个现有的 SQL Linq 连接和完整的 DBML。现在我需要将相同的代码转换为从 MySQL 访问(不要问为什么...它很复杂)。
我已经从 NuGet 安装了 Linq2DB(VS2019),并试图将代码转换为使用 Linq2DB 对象。
我包含了 DBML 设计器的代码页面的一部分,尽管可能只需要其中的一小部分来显示需要做的事情:

namespace MCAIntranet.LINQ
{
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.Data;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Linq;
    using System.Linq.Expressions;
    
    [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Corporate_Morning_Reports")]
    public partial class CMRDataContext : System.Data.Linq.DataContext
    {
        // 省略了其他成员和方法
        
        public CMRDataContext() : 
            base(global::System.Configuration.ConfigurationManager.ConnectionStrings["mcaintranetConnectionString"].ConnectionString, mappingSource)
        {
            OnCreated();
        }
        
        // 省略了其他构造函数和属性

        public System.Data.Linq.Table<MCAIntranet.LINQ.CMR.tblCollectorCode> tblCollectorCodes
        {
            get
            {
                return this.GetTable<MCAIntranet.LINQ.CMR.tblCollectorCode>();
            }
        }

        // 省略了其他表的属性
    }
}

namespace MCAIntranet.LINQ.CMR
{
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.ComponentModel;
    using System;
    
    [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.tblBranches")]
    public partial class tblBranch : INotifyPropertyChanging, INotifyPropertyChanged
    {
        // 省略了表的属性和事件

        public tblBranch()
        {
            this._tblCollectorCodes = new EntitySet<tblCollectorCode>(new Action<tblCollectorCode>(this.attach_tblCollectorCodes), new Action<tblCollectorCode>(this.detach_tblCollectorCodes));
            this._tblCommission = default(EntityRef<tblCommission>);
            this._tblCollectorCode = default(EntityRef<tblCollectorCode>);
            OnCreated();
        }

        // 省略了表的属性和方法
    }
    
    // 省略了其他表的定义
}

以上是一段关于将现有 SQL Linq 连接和 DBML 转换为 MySQL 访问的代码的部分。如果您需要更多信息或帮助,可以提出具体问题。

英文:

I have a project where an existing SQL Linq connection and full DBML has been created. Now I need to convert this same code to access from MySQL (Don't ask why... it's complicated).
I have install Linq2DB from NuGet (VS2019) and am attempting to convert the code to use the Linq2DB object.
I am including a portion of the code page for the DBML designer although likely only a small part is needed to show me what needs doing:

namespace MCAIntranet.LINQ
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name=&quot;Corporate_Morning_Reports&quot;)]
public partial class CMRDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void InserttblCollectorCode(MCAIntranet.LINQ.CMR.tblCollectorCode instance);
partial void UpdatetblCollectorCode(MCAIntranet.LINQ.CMR.tblCollectorCode instance);
partial void DeletetblCollectorCode(MCAIntranet.LINQ.CMR.tblCollectorCode instance);
partial void InserttblBranch(MCAIntranet.LINQ.CMR.tblBranch instance);
partial void UpdatetblBranch(MCAIntranet.LINQ.CMR.tblBranch instance);
partial void DeletetblBranch(MCAIntranet.LINQ.CMR.tblBranch instance);
partial void InserttblClient(MCAIntranet.LINQ.CMR.tblClient instance);
partial void UpdatetblClient(MCAIntranet.LINQ.CMR.tblClient instance);
partial void DeletetblClient(MCAIntranet.LINQ.CMR.tblClient instance);
partial void InserttblHoliday(MCAIntranet.LINQ.CMR.tblHoliday instance);
partial void UpdatetblHoliday(MCAIntranet.LINQ.CMR.tblHoliday instance);
partial void DeletetblHoliday(MCAIntranet.LINQ.CMR.tblHoliday instance);
partial void InserttblTarget(MCAIntranet.LINQ.CMR.tblTarget instance);
partial void UpdatetblTarget(MCAIntranet.LINQ.CMR.tblTarget instance);
partial void DeletetblTarget(MCAIntranet.LINQ.CMR.tblTarget instance);
partial void InserttblCollector(MCAIntranet.LINQ.CMR.tblCollector instance);
partial void UpdatetblCollector(MCAIntranet.LINQ.CMR.tblCollector instance);
partial void DeletetblCollector(MCAIntranet.LINQ.CMR.tblCollector instance);
partial void InserttblCommission(MCAIntranet.LINQ.CMR.tblCommission instance);
partial void UpdatetblCommission(MCAIntranet.LINQ.CMR.tblCommission instance);
partial void DeletetblCommission(MCAIntranet.LINQ.CMR.tblCommission instance);
partial void InserttblDeletedEmployee(MCAIntranet.LINQ.CMR.tblDeletedEmployee instance);
partial void UpdatetblDeletedEmployee(MCAIntranet.LINQ.CMR.tblDeletedEmployee instance);
partial void DeletetblDeletedEmployee(MCAIntranet.LINQ.CMR.tblDeletedEmployee instance);
partial void InserttblReportColor(MCAIntranet.LINQ.CMR.tblReportColor instance);
partial void UpdatetblReportColor(MCAIntranet.LINQ.CMR.tblReportColor instance);
partial void DeletetblReportColor(MCAIntranet.LINQ.CMR.tblReportColor instance);
partial void InserttblManager(MCAIntranet.LINQ.CMR.tblManager instance);
partial void UpdatetblManager(MCAIntranet.LINQ.CMR.tblManager instance);
partial void DeletetblManager(MCAIntranet.LINQ.CMR.tblManager instance);
partial void InserttblAccessLevel(MCAIntranet.LINQ.CMR.tblAccessLevel instance);
partial void UpdatetblAccessLevel(MCAIntranet.LINQ.CMR.tblAccessLevel instance);
partial void DeletetblAccessLevel(MCAIntranet.LINQ.CMR.tblAccessLevel instance);
partial void InserttblLanguage(MCAIntranet.LINQ.CMR.tblLanguage instance);
partial void UpdatetblLanguage(MCAIntranet.LINQ.CMR.tblLanguage instance);
partial void DeletetblLanguage(MCAIntranet.LINQ.CMR.tblLanguage instance);
partial void InserttblLanguagesSpoken(MCAIntranet.LINQ.CMR.tblLanguagesSpoken instance);
partial void UpdatetblLanguagesSpoken(MCAIntranet.LINQ.CMR.tblLanguagesSpoken instance);
partial void DeletetblLanguagesSpoken(MCAIntranet.LINQ.CMR.tblLanguagesSpoken instance);
#endregion
public CMRDataContext() : 
base(global::System.Configuration.ConfigurationManager.ConnectionStrings[&quot;mcaintranetConnectionString&quot;].ConnectionString, mappingSource)
{
OnCreated();
}
public CMRDataContext(string connection) : 
base(connection, mappingSource)
{
OnCreated();
}
public CMRDataContext(System.Data.IDbConnection connection) : 
base(connection, mappingSource)
{
OnCreated();
}
public CMRDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
base(connection, mappingSource)
{
OnCreated();
}
public CMRDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
base(connection, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblCollectorCode&gt; tblCollectorCodes
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblCollectorCode&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblBranch&gt; tblBranches
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblBranch&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblClient&gt; tblClients
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblClient&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblHoliday&gt; tblHolidays
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblHoliday&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblTarget&gt; tblTargets
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblTarget&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblPageValue&gt; tblPageValues
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblPageValue&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwCollector&gt; vwCollectors
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwCollector&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwManager&gt; vwManagers
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwManager&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwCodesCollector&gt; vwCodesCollectors
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwCodesCollector&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwDataHistory&gt; vwDataHistories
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwDataHistory&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwLanguage&gt; vwLanguages
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwLanguage&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwTarget&gt; vwTargets
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwTarget&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblCollector&gt; tblCollectors
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblCollector&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblCommission&gt; tblCommissions
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblCommission&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblDeletedEmployee&gt; tblDeletedEmployees
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblDeletedEmployee&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblReportColor&gt; tblReportColors
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblReportColor&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwEmployeeLicense&gt; vwEmployeeLicenses
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwEmployeeLicense&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblManager&gt; tblManagers
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblManager&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblAccessLevel&gt; tblAccessLevels
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblAccessLevel&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblLanguage&gt; tblLanguages
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblLanguage&gt;();
}
}
public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblLanguagesSpoken&gt; tblLanguagesSpokens
{
get
{
return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblLanguagesSpoken&gt;();
}
}
}
}
namespace MCAIntranet.LINQ.CMR
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System;
[global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.tblBranches&quot;)]
public partial class tblBranch : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _id;
private string _BranchName;
private string _BranchPhone;
private EntitySet&lt;tblCollectorCode&gt; _tblCollectorCodes;
private EntityRef&lt;tblCommission&gt; _tblCommission;
private EntityRef&lt;tblCollectorCode&gt; _tblCollectorCode;
public tblBranch()
{
this._tblCollectorCodes = new EntitySet&lt;tblCollectorCode&gt;(new Action&lt;tblCollectorCode&gt;(this.attach_tblCollectorCodes), new Action&lt;tblCollectorCode&gt;(this.detach_tblCollectorCodes));
this._tblCommission = default(EntityRef&lt;tblCommission&gt;);
this._tblCollectorCode = default(EntityRef&lt;tblCollectorCode&gt;);
OnCreated();
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_id&quot;, AutoSync=AutoSync.OnInsert, DbType=&quot;Int NOT NULL IDENTITY&quot;, IsPrimaryKey=true, IsDbGenerated=true)]
public int id
{
get
{
return this._id;
}
set
{
if ((this._id != value))
{
if ((this._tblCommission.HasLoadedOrAssignedValue || this._tblCollectorCode.HasLoadedOrAssignedValue))
{
throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
}
this.OnidChanging(value);
this.SendPropertyChanging();
this._id = value;
this.SendPropertyChanged(&quot;id&quot;);
this.OnidChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_BranchName&quot;, DbType=&quot;NVarChar(20) NOT NULL&quot;, CanBeNull=false)]
public string BranchName
{
get
{
return this._BranchName;
}
set
{
if ((this._BranchName != value))
{
this.OnBranchNameChanging(value);
this.SendPropertyChanging();
this._BranchName = value;
this.SendPropertyChanged(&quot;BranchName&quot;);
this.OnBranchNameChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_BranchPhone&quot;, DbType=&quot;NVarChar(13)&quot;)]
public string BranchPhone
{
get
{
return this._BranchPhone;
}
set
{
if ((this._BranchPhone != value))
{
this.OnBranchPhoneChanging(value);
this.SendPropertyChanging();
this._BranchPhone = value;
this.SendPropertyChanged(&quot;BranchPhone&quot;);
this.OnBranchPhoneChanged();
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblBranch_tblCollectorCode&quot;, Storage=&quot;_tblCollectorCodes&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;branch&quot;)]
public EntitySet&lt;tblCollectorCode&gt; tblCollectorCodes
{
get
{
return this._tblCollectorCodes;
}
set
{
this._tblCollectorCodes.Assign(value);
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblCommission_tblBranch&quot;, Storage=&quot;_tblCommission&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;branch&quot;, IsForeignKey=true)]
public tblCommission tblCommission
{
get
{
return this._tblCommission.Entity;
}
set
{
tblCommission previousValue = this._tblCommission.Entity;
if (((previousValue != value) 
|| (this._tblCommission.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._tblCommission.Entity = null;
previousValue.tblBranches.Remove(this);
}
this._tblCommission.Entity = value;
if ((value != null))
{
value.tblBranches.Add(this);
this._id = value.branch;
}
else
{
this._id = default(int);
}
this.SendPropertyChanged(&quot;tblCommission&quot;);
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblCollectorCode_tblBranch&quot;, Storage=&quot;_tblCollectorCode&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;branch&quot;, IsForeignKey=true)]
public tblCollectorCode tblCollectorCode
{
get
{
return this._tblCollectorCode.Entity;
}
set
{
tblCollectorCode previousValue = this._tblCollectorCode.Entity;
if (((previousValue != value) 
|| (this._tblCollectorCode.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._tblCollectorCode.Entity = null;
previousValue.tblBranches.Remove(this);
}
this._tblCollectorCode.Entity = value;
if ((value != null))
{
value.tblBranches.Add(this);
this._id = value.branch;
}
else
{
this._id = default(int);
}
this.SendPropertyChanged(&quot;tblCollectorCode&quot;);
}
}
}
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_tblCollectorCodes(tblCollectorCode entity)
{
this.SendPropertyChanging();
entity.tblBranch = this;
}
private void detach_tblCollectorCodes(tblCollectorCode entity)
{
this.SendPropertyChanging();
entity.tblBranch = null;
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.tblClients&quot;)]
public partial class tblClient : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _id;
private string _ClientName;
private string _ClientContact;
private string _ClientPhone;
private EntitySet&lt;tblCollectorCode&gt; _tblCollectorCodes;
private EntityRef&lt;tblCommission&gt; _tblCommission;
private EntityRef&lt;tblCollectorCode&gt; _tblCollectorCode;
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnidChanging(int value);
partial void OnidChanged();
partial void OnClientNameChanging(string value);
partial void OnClientNameChanged();
partial void OnClientContactChanging(string value);
partial void OnClientContactChanged();
partial void OnClientPhoneChanging(string value);
partial void OnClientPhoneChanged();
#endregion
public tblClient()
{
this._tblCollectorCodes = new EntitySet&lt;tblCollectorCode&gt;(new Action&lt;tblCollectorCode&gt;(this.attach_tblCollectorCodes), new Action&lt;tblCollectorCode&gt;(this.detach_tblCollectorCodes));
this._tblCommission = default(EntityRef&lt;tblCommission&gt;);
this._tblCollectorCode = default(EntityRef&lt;tblCollectorCode&gt;);
OnCreated();
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_id&quot;, AutoSync=AutoSync.OnInsert, DbType=&quot;Int NOT NULL IDENTITY&quot;, IsPrimaryKey=true, IsDbGenerated=true)]
public int id
{
get
{
return this._id;
}
set
{
if ((this._id != value))
{
if ((this._tblCommission.HasLoadedOrAssignedValue || this._tblCollectorCode.HasLoadedOrAssignedValue))
{
throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
}
this.OnidChanging(value);
this.SendPropertyChanging();
this._id = value;
this.SendPropertyChanged(&quot;id&quot;);
this.OnidChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_ClientName&quot;, DbType=&quot;NVarChar(50) NOT NULL&quot;, CanBeNull=false)]
public string ClientName
{
get
{
return this._ClientName;
}
set
{
if ((this._ClientName != value))
{
this.OnClientNameChanging(value);
this.SendPropertyChanging();
this._ClientName = value;
this.SendPropertyChanged(&quot;ClientName&quot;);
this.OnClientNameChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_ClientContact&quot;, DbType=&quot;NVarChar(50)&quot;)]
public string ClientContact
{
get
{
return this._ClientContact;
}
set
{
if ((this._ClientContact != value))
{
this.OnClientContactChanging(value);
this.SendPropertyChanging();
this._ClientContact = value;
this.SendPropertyChanged(&quot;ClientContact&quot;);
this.OnClientContactChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_ClientPhone&quot;, DbType=&quot;NVarChar(20)&quot;)]
public string ClientPhone
{
get
{
return this._ClientPhone;
}
set
{
if ((this._ClientPhone != value))
{
this.OnClientPhoneChanging(value);
this.SendPropertyChanging();
this._ClientPhone = value;
this.SendPropertyChanged(&quot;ClientPhone&quot;);
this.OnClientPhoneChanged();
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblClient_tblCollectorCode&quot;, Storage=&quot;_tblCollectorCodes&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;client&quot;)]
public EntitySet&lt;tblCollectorCode&gt; tblCollectorCodes
{
get
{
return this._tblCollectorCodes;
}
set
{
this._tblCollectorCodes.Assign(value);
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblCommission_tblClient&quot;, Storage=&quot;_tblCommission&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;client&quot;, IsForeignKey=true)]
public tblCommission tblCommission
{
get
{
return this._tblCommission.Entity;
}
set
{
tblCommission previousValue = this._tblCommission.Entity;
if (((previousValue != value) 
|| (this._tblCommission.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._tblCommission.Entity = null;
previousValue.tblClients.Remove(this);
}
this._tblCommission.Entity = value;
if ((value != null))
{
value.tblClients.Add(this);
this._id = value.client;
}
else
{
this._id = default(int);
}
this.SendPropertyChanged(&quot;tblCommission&quot;);
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblCollectorCode_tblClient&quot;, Storage=&quot;_tblCollectorCode&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;client&quot;, IsForeignKey=true)]
public tblCollectorCode tblCollectorCode
{
get
{
return this._tblCollectorCode.Entity;
}
set
{
tblCollectorCode previousValue = this._tblCollectorCode.Entity;
if (((previousValue != value) 
|| (this._tblCollectorCode.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._tblCollectorCode.Entity = null;
previousValue.tblClients.Remove(this);
}
this._tblCollectorCode.Entity = value;
if ((value != null))
{
value.tblClients.Add(this);
this._id = value.client;
}
else
{
this._id = default(int);
}
this.SendPropertyChanged(&quot;tblCollectorCode&quot;);
}
}
}
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_tblCollectorCodes(tblCollectorCode entity)
{
this.SendPropertyChanging();
entity.tblClient = this;
}
private void detach_tblCollectorCodes(tblCollectorCode entity)
{
this.SendPropertyChanging();
entity.tblClient = null;
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.vwTargets&quot;)]
public partial class vwTarget
{
private System.Nullable&lt;decimal&gt; _Target;
private System.Nullable&lt;decimal&gt; _StartDate;
private System.Nullable&lt;decimal&gt; _EndDate;
private System.Nullable&lt;decimal&gt; _id;
private string _Code;
public vwTarget()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Target&quot;, DbType=&quot;Decimal(10,2)&quot;)]
public System.Nullable&lt;decimal&gt; Target
{
get
{
return this._Target;
}
set
{
if ((this._Target != value))
{
this._Target = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_StartDate&quot;, DbType=&quot;Decimal(10,0)&quot;)]
public System.Nullable&lt;decimal&gt; StartDate
{
get
{
return this._StartDate;
}
set
{
if ((this._StartDate != value))
{
this._StartDate = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_EndDate&quot;, DbType=&quot;Decimal(10,0)&quot;)]
public System.Nullable&lt;decimal&gt; EndDate
{
get
{
return this._EndDate;
}
set
{
if ((this._EndDate != value))
{
this._EndDate = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_id&quot;, DbType=&quot;Decimal(10,0)&quot;)]
public System.Nullable&lt;decimal&gt; id
{
get
{
return this._id;
}
set
{
if ((this._id != value))
{
this._id = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Code&quot;, DbType=&quot;VarChar(20)&quot;)]
public string Code
{
get
{
return this._Code;
}
set
{
if ((this._Code != value))
{
this._Code = value;
}
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.vwEmployeeLicenses&quot;)]
public partial class vwEmployeeLicense
{
private string _PEmployeeID;
private string _PFirstName;
private string _PLastName;
private System.DateTime _Start_Date;
private System.DateTime _Terminated;
private string _Branch;
private System.Nullable&lt;int&gt; _BranchNumber;
public vwEmployeeLicense()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_PEmployeeID&quot;, DbType=&quot;Char(15) NOT NULL&quot;, CanBeNull=false)]
public string PEmployeeID
{
get
{
return this._PEmployeeID;
}
set
{
if ((this._PEmployeeID != value))
{
this._PEmployeeID = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_PFirstName&quot;, DbType=&quot;Char(15) NOT NULL&quot;, CanBeNull=false)]
public string PFirstName
{
get
{
return this._PFirstName;
}
set
{
if ((this._PFirstName != value))
{
this._PFirstName = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_PLastName&quot;, DbType=&quot;Char(21) NOT NULL&quot;, CanBeNull=false)]
public string PLastName
{
get
{
return this._PLastName;
}
set
{
if ((this._PLastName != value))
{
this._PLastName = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Name=&quot;[Start Date]&quot;, Storage=&quot;_Start_Date&quot;, DbType=&quot;DateTime NOT NULL&quot;)]
public System.DateTime Start_Date
{
get
{
return this._Start_Date;
}
set
{
if ((this._Start_Date != value))
{
this._Start_Date = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Terminated&quot;, DbType=&quot;DateTime NOT NULL&quot;)]
public System.DateTime Terminated
{
get
{
return this._Terminated;
}
set
{
if ((this._Terminated != value))
{
this._Terminated = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Branch&quot;, DbType=&quot;NVarChar(23)&quot;)]
public string Branch
{
get
{
return this._Branch;
}
set
{
if ((this._Branch != value))
{
this._Branch = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_BranchNumber&quot;, DbType=&quot;Int&quot;)]
public System.Nullable&lt;int&gt; BranchNumber
{
get
{
return this._BranchNumber;
}
set
{
if ((this._BranchNumber != value))
{
this._BranchNumber = value;
}
}
}
}
}

This code was generated by the Add New Linq To SQL object in the IDE. How can this be moved over to LinqToDB using MySQL?

答案1

得分: 0

Finally used the EntityFramework's scaffold-dbcontext command which accessed my database and pulled in all the necessary tables then created the related context for that table. Not graphical like I would prefer and joins will need to be handled manually but it's good enough for my uses.

英文:

Finally used the EntityFramework's scaffold-dbcontext command which accessed my database and pulled in all the necessary tables then created the related context for that table. Not graphical like I would prefer and joins will need to be handled manually but it's good enough for my uses

huangapple
  • 本文由 发表于 2023年3月9日 23:53:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687024.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定