Advertisement
Guest User

Untitled

a guest
May 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Linq;
  4. using System.Data.Linq.Mapping;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Seminarium;
  9.  
  10. namespace Seminarium
  11. {
  12. [Table(Name = "Regions")]
  13. public class Region
  14. {
  15. [Column(IsPrimaryKey = true)] public string region_id;
  16. [Column] public string region_name;
  17.  
  18. }
  19.  
  20. [Table(Name = "Countires")]
  21. public class Country
  22. {
  23. [Column(IsPrimaryKey = true)] public string country_id;
  24. [Column] public string country_name;
  25. [Column] public string region_id;
  26.  
  27. private EntityRef<Region> _Regions;
  28.  
  29. [Association(Name = "FK_Countries_Regions", Storage = "_Regions", ThisKey = "region_id", IsForeignKey = true)]
  30. public Region Region
  31. {
  32. get
  33. {
  34. return this._Regions.Entity;
  35. }
  36. set
  37. {
  38. Region previousValue = this._Regions.Entity;
  39. if (((previousValue != value)
  40. || (this._Regions.HasLoadedOrAssignedValue == false)))
  41. {
  42. this.SendPropertyChanging();
  43. if ((previousValue != null))
  44. {
  45. this._Regions.Entity = null;
  46. previousValue.Region.Remove(this);
  47. }
  48. this._Regions.Entity = value;
  49. if ((value != null))
  50. {
  51. value.Country.Add(this);
  52. this.region_id = value.region_id;
  53. }
  54. else
  55. {
  56. this.region_id = default(string);
  57. }
  58. this.SendPropertyChanged("Region");
  59. }
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement