从LinqToSQL转换为Linq2DB

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

Convert from LinqToSQL to Linq2DB

问题

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

  1. namespace MCAIntranet.LINQ
  2. {
  3. using System.Data.Linq;
  4. using System.Data.Linq.Mapping;
  5. using System.Data;
  6. using System.Collections.Generic;
  7. using System.Reflection;
  8. using System.Linq;
  9. using System.Linq.Expressions;
  10. [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Corporate_Morning_Reports")]
  11. public partial class CMRDataContext : System.Data.Linq.DataContext
  12. {
  13. // 省略了其他成员和方法
  14. public CMRDataContext() :
  15. base(global::System.Configuration.ConfigurationManager.ConnectionStrings["mcaintranetConnectionString"].ConnectionString, mappingSource)
  16. {
  17. OnCreated();
  18. }
  19. // 省略了其他构造函数和属性
  20. public System.Data.Linq.Table<MCAIntranet.LINQ.CMR.tblCollectorCode> tblCollectorCodes
  21. {
  22. get
  23. {
  24. return this.GetTable<MCAIntranet.LINQ.CMR.tblCollectorCode>();
  25. }
  26. }
  27. // 省略了其他表的属性
  28. }
  29. }
  30. namespace MCAIntranet.LINQ.CMR
  31. {
  32. using System.Data.Linq;
  33. using System.Data.Linq.Mapping;
  34. using System.ComponentModel;
  35. using System;
  36. [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.tblBranches")]
  37. public partial class tblBranch : INotifyPropertyChanging, INotifyPropertyChanged
  38. {
  39. // 省略了表的属性和事件
  40. public tblBranch()
  41. {
  42. this._tblCollectorCodes = new EntitySet<tblCollectorCode>(new Action<tblCollectorCode>(this.attach_tblCollectorCodes), new Action<tblCollectorCode>(this.detach_tblCollectorCodes));
  43. this._tblCommission = default(EntityRef<tblCommission>);
  44. this._tblCollectorCode = default(EntityRef<tblCollectorCode>);
  45. OnCreated();
  46. }
  47. // 省略了表的属性和方法
  48. }
  49. // 省略了其他表的定义
  50. }

以上是一段关于将现有 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:

  1. namespace MCAIntranet.LINQ
  2. {
  3. using System.Data.Linq;
  4. using System.Data.Linq.Mapping;
  5. using System.Data;
  6. using System.Collections.Generic;
  7. using System.Reflection;
  8. using System.Linq;
  9. using System.Linq.Expressions;
  10. [global::System.Data.Linq.Mapping.DatabaseAttribute(Name=&quot;Corporate_Morning_Reports&quot;)]
  11. public partial class CMRDataContext : System.Data.Linq.DataContext
  12. {
  13. private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
  14. #region Extensibility Method Definitions
  15. partial void OnCreated();
  16. partial void InserttblCollectorCode(MCAIntranet.LINQ.CMR.tblCollectorCode instance);
  17. partial void UpdatetblCollectorCode(MCAIntranet.LINQ.CMR.tblCollectorCode instance);
  18. partial void DeletetblCollectorCode(MCAIntranet.LINQ.CMR.tblCollectorCode instance);
  19. partial void InserttblBranch(MCAIntranet.LINQ.CMR.tblBranch instance);
  20. partial void UpdatetblBranch(MCAIntranet.LINQ.CMR.tblBranch instance);
  21. partial void DeletetblBranch(MCAIntranet.LINQ.CMR.tblBranch instance);
  22. partial void InserttblClient(MCAIntranet.LINQ.CMR.tblClient instance);
  23. partial void UpdatetblClient(MCAIntranet.LINQ.CMR.tblClient instance);
  24. partial void DeletetblClient(MCAIntranet.LINQ.CMR.tblClient instance);
  25. partial void InserttblHoliday(MCAIntranet.LINQ.CMR.tblHoliday instance);
  26. partial void UpdatetblHoliday(MCAIntranet.LINQ.CMR.tblHoliday instance);
  27. partial void DeletetblHoliday(MCAIntranet.LINQ.CMR.tblHoliday instance);
  28. partial void InserttblTarget(MCAIntranet.LINQ.CMR.tblTarget instance);
  29. partial void UpdatetblTarget(MCAIntranet.LINQ.CMR.tblTarget instance);
  30. partial void DeletetblTarget(MCAIntranet.LINQ.CMR.tblTarget instance);
  31. partial void InserttblCollector(MCAIntranet.LINQ.CMR.tblCollector instance);
  32. partial void UpdatetblCollector(MCAIntranet.LINQ.CMR.tblCollector instance);
  33. partial void DeletetblCollector(MCAIntranet.LINQ.CMR.tblCollector instance);
  34. partial void InserttblCommission(MCAIntranet.LINQ.CMR.tblCommission instance);
  35. partial void UpdatetblCommission(MCAIntranet.LINQ.CMR.tblCommission instance);
  36. partial void DeletetblCommission(MCAIntranet.LINQ.CMR.tblCommission instance);
  37. partial void InserttblDeletedEmployee(MCAIntranet.LINQ.CMR.tblDeletedEmployee instance);
  38. partial void UpdatetblDeletedEmployee(MCAIntranet.LINQ.CMR.tblDeletedEmployee instance);
  39. partial void DeletetblDeletedEmployee(MCAIntranet.LINQ.CMR.tblDeletedEmployee instance);
  40. partial void InserttblReportColor(MCAIntranet.LINQ.CMR.tblReportColor instance);
  41. partial void UpdatetblReportColor(MCAIntranet.LINQ.CMR.tblReportColor instance);
  42. partial void DeletetblReportColor(MCAIntranet.LINQ.CMR.tblReportColor instance);
  43. partial void InserttblManager(MCAIntranet.LINQ.CMR.tblManager instance);
  44. partial void UpdatetblManager(MCAIntranet.LINQ.CMR.tblManager instance);
  45. partial void DeletetblManager(MCAIntranet.LINQ.CMR.tblManager instance);
  46. partial void InserttblAccessLevel(MCAIntranet.LINQ.CMR.tblAccessLevel instance);
  47. partial void UpdatetblAccessLevel(MCAIntranet.LINQ.CMR.tblAccessLevel instance);
  48. partial void DeletetblAccessLevel(MCAIntranet.LINQ.CMR.tblAccessLevel instance);
  49. partial void InserttblLanguage(MCAIntranet.LINQ.CMR.tblLanguage instance);
  50. partial void UpdatetblLanguage(MCAIntranet.LINQ.CMR.tblLanguage instance);
  51. partial void DeletetblLanguage(MCAIntranet.LINQ.CMR.tblLanguage instance);
  52. partial void InserttblLanguagesSpoken(MCAIntranet.LINQ.CMR.tblLanguagesSpoken instance);
  53. partial void UpdatetblLanguagesSpoken(MCAIntranet.LINQ.CMR.tblLanguagesSpoken instance);
  54. partial void DeletetblLanguagesSpoken(MCAIntranet.LINQ.CMR.tblLanguagesSpoken instance);
  55. #endregion
  56. public CMRDataContext() :
  57. base(global::System.Configuration.ConfigurationManager.ConnectionStrings[&quot;mcaintranetConnectionString&quot;].ConnectionString, mappingSource)
  58. {
  59. OnCreated();
  60. }
  61. public CMRDataContext(string connection) :
  62. base(connection, mappingSource)
  63. {
  64. OnCreated();
  65. }
  66. public CMRDataContext(System.Data.IDbConnection connection) :
  67. base(connection, mappingSource)
  68. {
  69. OnCreated();
  70. }
  71. public CMRDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
  72. base(connection, mappingSource)
  73. {
  74. OnCreated();
  75. }
  76. public CMRDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
  77. base(connection, mappingSource)
  78. {
  79. OnCreated();
  80. }
  81. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblCollectorCode&gt; tblCollectorCodes
  82. {
  83. get
  84. {
  85. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblCollectorCode&gt;();
  86. }
  87. }
  88. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblBranch&gt; tblBranches
  89. {
  90. get
  91. {
  92. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblBranch&gt;();
  93. }
  94. }
  95. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblClient&gt; tblClients
  96. {
  97. get
  98. {
  99. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblClient&gt;();
  100. }
  101. }
  102. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblHoliday&gt; tblHolidays
  103. {
  104. get
  105. {
  106. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblHoliday&gt;();
  107. }
  108. }
  109. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblTarget&gt; tblTargets
  110. {
  111. get
  112. {
  113. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblTarget&gt;();
  114. }
  115. }
  116. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblPageValue&gt; tblPageValues
  117. {
  118. get
  119. {
  120. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblPageValue&gt;();
  121. }
  122. }
  123. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwCollector&gt; vwCollectors
  124. {
  125. get
  126. {
  127. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwCollector&gt;();
  128. }
  129. }
  130. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwManager&gt; vwManagers
  131. {
  132. get
  133. {
  134. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwManager&gt;();
  135. }
  136. }
  137. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwCodesCollector&gt; vwCodesCollectors
  138. {
  139. get
  140. {
  141. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwCodesCollector&gt;();
  142. }
  143. }
  144. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwDataHistory&gt; vwDataHistories
  145. {
  146. get
  147. {
  148. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwDataHistory&gt;();
  149. }
  150. }
  151. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwLanguage&gt; vwLanguages
  152. {
  153. get
  154. {
  155. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwLanguage&gt;();
  156. }
  157. }
  158. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwTarget&gt; vwTargets
  159. {
  160. get
  161. {
  162. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwTarget&gt;();
  163. }
  164. }
  165. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblCollector&gt; tblCollectors
  166. {
  167. get
  168. {
  169. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblCollector&gt;();
  170. }
  171. }
  172. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblCommission&gt; tblCommissions
  173. {
  174. get
  175. {
  176. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblCommission&gt;();
  177. }
  178. }
  179. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblDeletedEmployee&gt; tblDeletedEmployees
  180. {
  181. get
  182. {
  183. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblDeletedEmployee&gt;();
  184. }
  185. }
  186. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblReportColor&gt; tblReportColors
  187. {
  188. get
  189. {
  190. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblReportColor&gt;();
  191. }
  192. }
  193. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.vwEmployeeLicense&gt; vwEmployeeLicenses
  194. {
  195. get
  196. {
  197. return this.GetTable&lt;MCAIntranet.LINQ.CMR.vwEmployeeLicense&gt;();
  198. }
  199. }
  200. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblManager&gt; tblManagers
  201. {
  202. get
  203. {
  204. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblManager&gt;();
  205. }
  206. }
  207. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblAccessLevel&gt; tblAccessLevels
  208. {
  209. get
  210. {
  211. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblAccessLevel&gt;();
  212. }
  213. }
  214. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblLanguage&gt; tblLanguages
  215. {
  216. get
  217. {
  218. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblLanguage&gt;();
  219. }
  220. }
  221. public System.Data.Linq.Table&lt;MCAIntranet.LINQ.CMR.tblLanguagesSpoken&gt; tblLanguagesSpokens
  222. {
  223. get
  224. {
  225. return this.GetTable&lt;MCAIntranet.LINQ.CMR.tblLanguagesSpoken&gt;();
  226. }
  227. }
  228. }
  229. }
  230. namespace MCAIntranet.LINQ.CMR
  231. {
  232. using System.Data.Linq;
  233. using System.Data.Linq.Mapping;
  234. using System.ComponentModel;
  235. using System;
  236. [global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.tblBranches&quot;)]
  237. public partial class tblBranch : INotifyPropertyChanging, INotifyPropertyChanged
  238. {
  239. private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
  240. private int _id;
  241. private string _BranchName;
  242. private string _BranchPhone;
  243. private EntitySet&lt;tblCollectorCode&gt; _tblCollectorCodes;
  244. private EntityRef&lt;tblCommission&gt; _tblCommission;
  245. private EntityRef&lt;tblCollectorCode&gt; _tblCollectorCode;
  246. public tblBranch()
  247. {
  248. this._tblCollectorCodes = new EntitySet&lt;tblCollectorCode&gt;(new Action&lt;tblCollectorCode&gt;(this.attach_tblCollectorCodes), new Action&lt;tblCollectorCode&gt;(this.detach_tblCollectorCodes));
  249. this._tblCommission = default(EntityRef&lt;tblCommission&gt;);
  250. this._tblCollectorCode = default(EntityRef&lt;tblCollectorCode&gt;);
  251. OnCreated();
  252. }
  253. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_id&quot;, AutoSync=AutoSync.OnInsert, DbType=&quot;Int NOT NULL IDENTITY&quot;, IsPrimaryKey=true, IsDbGenerated=true)]
  254. public int id
  255. {
  256. get
  257. {
  258. return this._id;
  259. }
  260. set
  261. {
  262. if ((this._id != value))
  263. {
  264. if ((this._tblCommission.HasLoadedOrAssignedValue || this._tblCollectorCode.HasLoadedOrAssignedValue))
  265. {
  266. throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
  267. }
  268. this.OnidChanging(value);
  269. this.SendPropertyChanging();
  270. this._id = value;
  271. this.SendPropertyChanged(&quot;id&quot;);
  272. this.OnidChanged();
  273. }
  274. }
  275. }
  276. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_BranchName&quot;, DbType=&quot;NVarChar(20) NOT NULL&quot;, CanBeNull=false)]
  277. public string BranchName
  278. {
  279. get
  280. {
  281. return this._BranchName;
  282. }
  283. set
  284. {
  285. if ((this._BranchName != value))
  286. {
  287. this.OnBranchNameChanging(value);
  288. this.SendPropertyChanging();
  289. this._BranchName = value;
  290. this.SendPropertyChanged(&quot;BranchName&quot;);
  291. this.OnBranchNameChanged();
  292. }
  293. }
  294. }
  295. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_BranchPhone&quot;, DbType=&quot;NVarChar(13)&quot;)]
  296. public string BranchPhone
  297. {
  298. get
  299. {
  300. return this._BranchPhone;
  301. }
  302. set
  303. {
  304. if ((this._BranchPhone != value))
  305. {
  306. this.OnBranchPhoneChanging(value);
  307. this.SendPropertyChanging();
  308. this._BranchPhone = value;
  309. this.SendPropertyChanged(&quot;BranchPhone&quot;);
  310. this.OnBranchPhoneChanged();
  311. }
  312. }
  313. }
  314. [global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblBranch_tblCollectorCode&quot;, Storage=&quot;_tblCollectorCodes&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;branch&quot;)]
  315. public EntitySet&lt;tblCollectorCode&gt; tblCollectorCodes
  316. {
  317. get
  318. {
  319. return this._tblCollectorCodes;
  320. }
  321. set
  322. {
  323. this._tblCollectorCodes.Assign(value);
  324. }
  325. }
  326. [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)]
  327. public tblCommission tblCommission
  328. {
  329. get
  330. {
  331. return this._tblCommission.Entity;
  332. }
  333. set
  334. {
  335. tblCommission previousValue = this._tblCommission.Entity;
  336. if (((previousValue != value)
  337. || (this._tblCommission.HasLoadedOrAssignedValue == false)))
  338. {
  339. this.SendPropertyChanging();
  340. if ((previousValue != null))
  341. {
  342. this._tblCommission.Entity = null;
  343. previousValue.tblBranches.Remove(this);
  344. }
  345. this._tblCommission.Entity = value;
  346. if ((value != null))
  347. {
  348. value.tblBranches.Add(this);
  349. this._id = value.branch;
  350. }
  351. else
  352. {
  353. this._id = default(int);
  354. }
  355. this.SendPropertyChanged(&quot;tblCommission&quot;);
  356. }
  357. }
  358. }
  359. [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)]
  360. public tblCollectorCode tblCollectorCode
  361. {
  362. get
  363. {
  364. return this._tblCollectorCode.Entity;
  365. }
  366. set
  367. {
  368. tblCollectorCode previousValue = this._tblCollectorCode.Entity;
  369. if (((previousValue != value)
  370. || (this._tblCollectorCode.HasLoadedOrAssignedValue == false)))
  371. {
  372. this.SendPropertyChanging();
  373. if ((previousValue != null))
  374. {
  375. this._tblCollectorCode.Entity = null;
  376. previousValue.tblBranches.Remove(this);
  377. }
  378. this._tblCollectorCode.Entity = value;
  379. if ((value != null))
  380. {
  381. value.tblBranches.Add(this);
  382. this._id = value.branch;
  383. }
  384. else
  385. {
  386. this._id = default(int);
  387. }
  388. this.SendPropertyChanged(&quot;tblCollectorCode&quot;);
  389. }
  390. }
  391. }
  392. public event PropertyChangingEventHandler PropertyChanging;
  393. public event PropertyChangedEventHandler PropertyChanged;
  394. protected virtual void SendPropertyChanging()
  395. {
  396. if ((this.PropertyChanging != null))
  397. {
  398. this.PropertyChanging(this, emptyChangingEventArgs);
  399. }
  400. }
  401. protected virtual void SendPropertyChanged(String propertyName)
  402. {
  403. if ((this.PropertyChanged != null))
  404. {
  405. this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  406. }
  407. }
  408. private void attach_tblCollectorCodes(tblCollectorCode entity)
  409. {
  410. this.SendPropertyChanging();
  411. entity.tblBranch = this;
  412. }
  413. private void detach_tblCollectorCodes(tblCollectorCode entity)
  414. {
  415. this.SendPropertyChanging();
  416. entity.tblBranch = null;
  417. }
  418. }
  419. [global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.tblClients&quot;)]
  420. public partial class tblClient : INotifyPropertyChanging, INotifyPropertyChanged
  421. {
  422. private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
  423. private int _id;
  424. private string _ClientName;
  425. private string _ClientContact;
  426. private string _ClientPhone;
  427. private EntitySet&lt;tblCollectorCode&gt; _tblCollectorCodes;
  428. private EntityRef&lt;tblCommission&gt; _tblCommission;
  429. private EntityRef&lt;tblCollectorCode&gt; _tblCollectorCode;
  430. partial void OnLoaded();
  431. partial void OnValidate(System.Data.Linq.ChangeAction action);
  432. partial void OnCreated();
  433. partial void OnidChanging(int value);
  434. partial void OnidChanged();
  435. partial void OnClientNameChanging(string value);
  436. partial void OnClientNameChanged();
  437. partial void OnClientContactChanging(string value);
  438. partial void OnClientContactChanged();
  439. partial void OnClientPhoneChanging(string value);
  440. partial void OnClientPhoneChanged();
  441. #endregion
  442. public tblClient()
  443. {
  444. this._tblCollectorCodes = new EntitySet&lt;tblCollectorCode&gt;(new Action&lt;tblCollectorCode&gt;(this.attach_tblCollectorCodes), new Action&lt;tblCollectorCode&gt;(this.detach_tblCollectorCodes));
  445. this._tblCommission = default(EntityRef&lt;tblCommission&gt;);
  446. this._tblCollectorCode = default(EntityRef&lt;tblCollectorCode&gt;);
  447. OnCreated();
  448. }
  449. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_id&quot;, AutoSync=AutoSync.OnInsert, DbType=&quot;Int NOT NULL IDENTITY&quot;, IsPrimaryKey=true, IsDbGenerated=true)]
  450. public int id
  451. {
  452. get
  453. {
  454. return this._id;
  455. }
  456. set
  457. {
  458. if ((this._id != value))
  459. {
  460. if ((this._tblCommission.HasLoadedOrAssignedValue || this._tblCollectorCode.HasLoadedOrAssignedValue))
  461. {
  462. throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
  463. }
  464. this.OnidChanging(value);
  465. this.SendPropertyChanging();
  466. this._id = value;
  467. this.SendPropertyChanged(&quot;id&quot;);
  468. this.OnidChanged();
  469. }
  470. }
  471. }
  472. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_ClientName&quot;, DbType=&quot;NVarChar(50) NOT NULL&quot;, CanBeNull=false)]
  473. public string ClientName
  474. {
  475. get
  476. {
  477. return this._ClientName;
  478. }
  479. set
  480. {
  481. if ((this._ClientName != value))
  482. {
  483. this.OnClientNameChanging(value);
  484. this.SendPropertyChanging();
  485. this._ClientName = value;
  486. this.SendPropertyChanged(&quot;ClientName&quot;);
  487. this.OnClientNameChanged();
  488. }
  489. }
  490. }
  491. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_ClientContact&quot;, DbType=&quot;NVarChar(50)&quot;)]
  492. public string ClientContact
  493. {
  494. get
  495. {
  496. return this._ClientContact;
  497. }
  498. set
  499. {
  500. if ((this._ClientContact != value))
  501. {
  502. this.OnClientContactChanging(value);
  503. this.SendPropertyChanging();
  504. this._ClientContact = value;
  505. this.SendPropertyChanged(&quot;ClientContact&quot;);
  506. this.OnClientContactChanged();
  507. }
  508. }
  509. }
  510. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_ClientPhone&quot;, DbType=&quot;NVarChar(20)&quot;)]
  511. public string ClientPhone
  512. {
  513. get
  514. {
  515. return this._ClientPhone;
  516. }
  517. set
  518. {
  519. if ((this._ClientPhone != value))
  520. {
  521. this.OnClientPhoneChanging(value);
  522. this.SendPropertyChanging();
  523. this._ClientPhone = value;
  524. this.SendPropertyChanged(&quot;ClientPhone&quot;);
  525. this.OnClientPhoneChanged();
  526. }
  527. }
  528. }
  529. [global::System.Data.Linq.Mapping.AssociationAttribute(Name=&quot;tblClient_tblCollectorCode&quot;, Storage=&quot;_tblCollectorCodes&quot;, ThisKey=&quot;id&quot;, OtherKey=&quot;client&quot;)]
  530. public EntitySet&lt;tblCollectorCode&gt; tblCollectorCodes
  531. {
  532. get
  533. {
  534. return this._tblCollectorCodes;
  535. }
  536. set
  537. {
  538. this._tblCollectorCodes.Assign(value);
  539. }
  540. }
  541. [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)]
  542. public tblCommission tblCommission
  543. {
  544. get
  545. {
  546. return this._tblCommission.Entity;
  547. }
  548. set
  549. {
  550. tblCommission previousValue = this._tblCommission.Entity;
  551. if (((previousValue != value)
  552. || (this._tblCommission.HasLoadedOrAssignedValue == false)))
  553. {
  554. this.SendPropertyChanging();
  555. if ((previousValue != null))
  556. {
  557. this._tblCommission.Entity = null;
  558. previousValue.tblClients.Remove(this);
  559. }
  560. this._tblCommission.Entity = value;
  561. if ((value != null))
  562. {
  563. value.tblClients.Add(this);
  564. this._id = value.client;
  565. }
  566. else
  567. {
  568. this._id = default(int);
  569. }
  570. this.SendPropertyChanged(&quot;tblCommission&quot;);
  571. }
  572. }
  573. }
  574. [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)]
  575. public tblCollectorCode tblCollectorCode
  576. {
  577. get
  578. {
  579. return this._tblCollectorCode.Entity;
  580. }
  581. set
  582. {
  583. tblCollectorCode previousValue = this._tblCollectorCode.Entity;
  584. if (((previousValue != value)
  585. || (this._tblCollectorCode.HasLoadedOrAssignedValue == false)))
  586. {
  587. this.SendPropertyChanging();
  588. if ((previousValue != null))
  589. {
  590. this._tblCollectorCode.Entity = null;
  591. previousValue.tblClients.Remove(this);
  592. }
  593. this._tblCollectorCode.Entity = value;
  594. if ((value != null))
  595. {
  596. value.tblClients.Add(this);
  597. this._id = value.client;
  598. }
  599. else
  600. {
  601. this._id = default(int);
  602. }
  603. this.SendPropertyChanged(&quot;tblCollectorCode&quot;);
  604. }
  605. }
  606. }
  607. public event PropertyChangingEventHandler PropertyChanging;
  608. public event PropertyChangedEventHandler PropertyChanged;
  609. protected virtual void SendPropertyChanging()
  610. {
  611. if ((this.PropertyChanging != null))
  612. {
  613. this.PropertyChanging(this, emptyChangingEventArgs);
  614. }
  615. }
  616. protected virtual void SendPropertyChanged(String propertyName)
  617. {
  618. if ((this.PropertyChanged != null))
  619. {
  620. this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  621. }
  622. }
  623. private void attach_tblCollectorCodes(tblCollectorCode entity)
  624. {
  625. this.SendPropertyChanging();
  626. entity.tblClient = this;
  627. }
  628. private void detach_tblCollectorCodes(tblCollectorCode entity)
  629. {
  630. this.SendPropertyChanging();
  631. entity.tblClient = null;
  632. }
  633. }
  634. [global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.vwTargets&quot;)]
  635. public partial class vwTarget
  636. {
  637. private System.Nullable&lt;decimal&gt; _Target;
  638. private System.Nullable&lt;decimal&gt; _StartDate;
  639. private System.Nullable&lt;decimal&gt; _EndDate;
  640. private System.Nullable&lt;decimal&gt; _id;
  641. private string _Code;
  642. public vwTarget()
  643. {
  644. }
  645. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Target&quot;, DbType=&quot;Decimal(10,2)&quot;)]
  646. public System.Nullable&lt;decimal&gt; Target
  647. {
  648. get
  649. {
  650. return this._Target;
  651. }
  652. set
  653. {
  654. if ((this._Target != value))
  655. {
  656. this._Target = value;
  657. }
  658. }
  659. }
  660. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_StartDate&quot;, DbType=&quot;Decimal(10,0)&quot;)]
  661. public System.Nullable&lt;decimal&gt; StartDate
  662. {
  663. get
  664. {
  665. return this._StartDate;
  666. }
  667. set
  668. {
  669. if ((this._StartDate != value))
  670. {
  671. this._StartDate = value;
  672. }
  673. }
  674. }
  675. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_EndDate&quot;, DbType=&quot;Decimal(10,0)&quot;)]
  676. public System.Nullable&lt;decimal&gt; EndDate
  677. {
  678. get
  679. {
  680. return this._EndDate;
  681. }
  682. set
  683. {
  684. if ((this._EndDate != value))
  685. {
  686. this._EndDate = value;
  687. }
  688. }
  689. }
  690. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_id&quot;, DbType=&quot;Decimal(10,0)&quot;)]
  691. public System.Nullable&lt;decimal&gt; id
  692. {
  693. get
  694. {
  695. return this._id;
  696. }
  697. set
  698. {
  699. if ((this._id != value))
  700. {
  701. this._id = value;
  702. }
  703. }
  704. }
  705. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Code&quot;, DbType=&quot;VarChar(20)&quot;)]
  706. public string Code
  707. {
  708. get
  709. {
  710. return this._Code;
  711. }
  712. set
  713. {
  714. if ((this._Code != value))
  715. {
  716. this._Code = value;
  717. }
  718. }
  719. }
  720. }
  721. [global::System.Data.Linq.Mapping.TableAttribute(Name=&quot;dbo.vwEmployeeLicenses&quot;)]
  722. public partial class vwEmployeeLicense
  723. {
  724. private string _PEmployeeID;
  725. private string _PFirstName;
  726. private string _PLastName;
  727. private System.DateTime _Start_Date;
  728. private System.DateTime _Terminated;
  729. private string _Branch;
  730. private System.Nullable&lt;int&gt; _BranchNumber;
  731. public vwEmployeeLicense()
  732. {
  733. }
  734. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_PEmployeeID&quot;, DbType=&quot;Char(15) NOT NULL&quot;, CanBeNull=false)]
  735. public string PEmployeeID
  736. {
  737. get
  738. {
  739. return this._PEmployeeID;
  740. }
  741. set
  742. {
  743. if ((this._PEmployeeID != value))
  744. {
  745. this._PEmployeeID = value;
  746. }
  747. }
  748. }
  749. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_PFirstName&quot;, DbType=&quot;Char(15) NOT NULL&quot;, CanBeNull=false)]
  750. public string PFirstName
  751. {
  752. get
  753. {
  754. return this._PFirstName;
  755. }
  756. set
  757. {
  758. if ((this._PFirstName != value))
  759. {
  760. this._PFirstName = value;
  761. }
  762. }
  763. }
  764. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_PLastName&quot;, DbType=&quot;Char(21) NOT NULL&quot;, CanBeNull=false)]
  765. public string PLastName
  766. {
  767. get
  768. {
  769. return this._PLastName;
  770. }
  771. set
  772. {
  773. if ((this._PLastName != value))
  774. {
  775. this._PLastName = value;
  776. }
  777. }
  778. }
  779. [global::System.Data.Linq.Mapping.ColumnAttribute(Name=&quot;[Start Date]&quot;, Storage=&quot;_Start_Date&quot;, DbType=&quot;DateTime NOT NULL&quot;)]
  780. public System.DateTime Start_Date
  781. {
  782. get
  783. {
  784. return this._Start_Date;
  785. }
  786. set
  787. {
  788. if ((this._Start_Date != value))
  789. {
  790. this._Start_Date = value;
  791. }
  792. }
  793. }
  794. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Terminated&quot;, DbType=&quot;DateTime NOT NULL&quot;)]
  795. public System.DateTime Terminated
  796. {
  797. get
  798. {
  799. return this._Terminated;
  800. }
  801. set
  802. {
  803. if ((this._Terminated != value))
  804. {
  805. this._Terminated = value;
  806. }
  807. }
  808. }
  809. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_Branch&quot;, DbType=&quot;NVarChar(23)&quot;)]
  810. public string Branch
  811. {
  812. get
  813. {
  814. return this._Branch;
  815. }
  816. set
  817. {
  818. if ((this._Branch != value))
  819. {
  820. this._Branch = value;
  821. }
  822. }
  823. }
  824. [global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&quot;_BranchNumber&quot;, DbType=&quot;Int&quot;)]
  825. public System.Nullable&lt;int&gt; BranchNumber
  826. {
  827. get
  828. {
  829. return this._BranchNumber;
  830. }
  831. set
  832. {
  833. if ((this._BranchNumber != value))
  834. {
  835. this._BranchNumber = value;
  836. }
  837. }
  838. }
  839. }
  840. }

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:

确定