dblinq-experiment
changeset 2:9c9c6be70123 tip
Greatly simplified the db entities code
As usual, the simplification required some DbLinq fixes.
As usual, the simplification required some DbLinq fixes.
| author | Emanuele Aina <em@nerd.ocracy.org> |
|---|---|
| date | Fri Sep 04 15:08:29 2009 +0200 (10 months ago) |
| parents | 248fb7a05b8d |
| children | |
| files | db/Db.cs lib/DbLinq.PostgreSql.dll lib/DbLinq.PostgreSql.dll.mdb lib/DbLinq.dll lib/DbLinq.dll.mdb |
line diff
1.1 --- a/db/Db.cs Fri Sep 04 14:50:39 2009 +0200 1.2 +++ b/db/Db.cs Fri Sep 04 15:08:29 2009 +0200 1.3 @@ -9,93 +9,17 @@ 1.4 1.5 namespace Experiment.Db 1.6 { 1.7 -[Table(Name = "public.child")] 1.8 -public partial class Child : INotifyPropertyChanged 1.9 +[Table(Name = "child")] 1.10 +public partial class Child 1.11 { 1.12 - #region INotifyPropertyChanged handling 1.13 + [Column(Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.Never, Expression = "nextval('child_id_seq')")] 1.14 + public int Id { get; set; } 1.15 1.16 - public event PropertyChangedEventHandler PropertyChanged; 1.17 + [Column(Name = "number", DbType = "integer(32,0)", AutoSync = AutoSync.Never, CanBeNull = true)] 1.18 + public int Number { get; set; } 1.19 1.20 - protected virtual void OnPropertyChanged(string propertyName) 1.21 - { 1.22 - if (PropertyChanged != null) 1.23 - { 1.24 - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 1.25 - } 1.26 - } 1.27 - 1.28 - #endregion 1.29 - 1.30 - #region int Id 1.31 - 1.32 - public int _id; 1.33 - [DebuggerNonUserCode] 1.34 - [Column(Storage = "_id", Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.Never, Expression = "nextval('child_id_seq')")] 1.35 - public int Id 1.36 - { 1.37 - get 1.38 - { 1.39 - return _id; 1.40 - } 1.41 - set 1.42 - { 1.43 - if (value != _id) 1.44 - { 1.45 - _id = value; 1.46 - OnPropertyChanged("Id"); 1.47 - } 1.48 - } 1.49 - } 1.50 - 1.51 - #endregion 1.52 - 1.53 - #region int? Number 1.54 - 1.55 - public int? _number; 1.56 - [DebuggerNonUserCode] 1.57 - [Column(Storage = "_number", Name = "number", DbType = "integer(32,0)", AutoSync = AutoSync.Never, CanBeNull = true)] 1.58 - public int? Number 1.59 - { 1.60 - get 1.61 - { 1.62 - return _number; 1.63 - } 1.64 - set 1.65 - { 1.66 - if (value != _number) 1.67 - { 1.68 - _number = value; 1.69 - OnPropertyChanged("Number"); 1.70 - } 1.71 - } 1.72 - } 1.73 - 1.74 - #endregion 1.75 - 1.76 - #region int? Parent 1.77 - 1.78 - public int? _parentId; 1.79 - [DebuggerNonUserCode] 1.80 - [Column(Storage = "_parentId", Name = "parent", DbType = "integer(32,0)", AutoSync = AutoSync.Never, CanBeNull = true)] 1.81 - public int? ParentId 1.82 - { 1.83 - get 1.84 - { 1.85 - return _parentId; 1.86 - } 1.87 - set 1.88 - { 1.89 - if (value != _parentId) 1.90 - { 1.91 - _parentId = value; 1.92 - OnPropertyChanged("ParentId"); 1.93 - } 1.94 - } 1.95 - } 1.96 - 1.97 - #endregion 1.98 - 1.99 - #region Parents 1.100 + [Column(Name = "parent", DbType = "integer(32,0)", AutoSync = AutoSync.Never, CanBeNull = true)] 1.101 + public int? ParentId { get; set; } 1.102 1.103 public EntityRef<Parent> _parent; 1.104 [Association(Storage = "_parent", OtherKey = "Id", ThisKey = "ParentId", Name = "child_parent_fkey", IsForeignKey = true)] 1.105 @@ -120,137 +44,40 @@ 1.106 if (value != null) 1.107 { 1.108 value.Child.Add(this); 1.109 - _parentId = value.Id; 1.110 + ParentId = value.Id; 1.111 } 1.112 else 1.113 { 1.114 - _parentId = null; 1.115 + ParentId = null; 1.116 } 1.117 } 1.118 } 1.119 } 1.120 1.121 - 1.122 - #endregion 1.123 - 1.124 - #region ctor 1.125 - 1.126 public Child() 1.127 { 1.128 _parent = new EntityRef<Parent>(); 1.129 } 1.130 - 1.131 - #endregion 1.132 - 1.133 } 1.134 1.135 -[Table(Name = "public.parent")] 1.136 -public partial class Parent : INotifyPropertyChanged 1.137 +[Table(Name = "parent")] 1.138 +public partial class Parent 1.139 { 1.140 - #region INotifyPropertyChanged handling 1.141 + [Column(Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.Never, Expression = "nextval('parent_id_seq')")] 1.142 + public int Id { get; set; } 1.143 1.144 - public event PropertyChangedEventHandler PropertyChanged; 1.145 + [Column(Name = "name", DbType = "text", AutoSync = AutoSync.Never, CanBeNull = true)] 1.146 + public string Name { get; set; } 1.147 1.148 - protected virtual void OnPropertyChanged(string propertyName) 1.149 - { 1.150 - if (PropertyChanged != null) 1.151 - { 1.152 - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 1.153 - } 1.154 - } 1.155 1.156 - #endregion 1.157 + [Association(OtherKey = "ParentId", ThisKey = "Id", Name = "child_parent_fkey")] 1.158 + public EntitySet<Child> Child { get; set; } 1.159 1.160 - #region int Id 1.161 - 1.162 - public int _id; 1.163 - [DebuggerNonUserCode] 1.164 - [Column(Storage = "_id", Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.Never, Expression = "nextval('parent_id_seq')")] 1.165 - public int Id 1.166 - { 1.167 - get 1.168 - { 1.169 - return _id; 1.170 - } 1.171 - set 1.172 - { 1.173 - if (value != _id) 1.174 - { 1.175 - _id = value; 1.176 - OnPropertyChanged("Id"); 1.177 - } 1.178 - } 1.179 - } 1.180 - 1.181 - #endregion 1.182 - 1.183 - #region string Name 1.184 - 1.185 - public string _name; 1.186 - [DebuggerNonUserCode] 1.187 - [Column(Storage = "_name", Name = "name", DbType = "text", AutoSync = AutoSync.Never, CanBeNull = true)] 1.188 - public string Name 1.189 - { 1.190 - get 1.191 - { 1.192 - return _name; 1.193 - } 1.194 - set 1.195 - { 1.196 - if (value != _name) 1.197 - { 1.198 - _name = value; 1.199 - OnPropertyChanged("Name"); 1.200 - } 1.201 - } 1.202 - } 1.203 - 1.204 - #endregion 1.205 - 1.206 - #region Children 1.207 - 1.208 - public EntitySet<Child> _child; 1.209 - [Association(Storage = "_child", OtherKey = "ParentId", ThisKey = "Id", Name = "child_parent_fkey")] 1.210 - [DebuggerNonUserCode] 1.211 - public EntitySet<Child> Child 1.212 - { 1.213 - get 1.214 - { 1.215 - return _child; 1.216 - } 1.217 - set 1.218 - { 1.219 - _child = value; 1.220 - } 1.221 - } 1.222 - 1.223 - 1.224 - #endregion 1.225 - 1.226 - #region Attachement handlers 1.227 - 1.228 - public void Child_Attach(Child entity) 1.229 - { 1.230 - entity.Parent = this; 1.231 - } 1.232 - 1.233 - public void Child_Detach(Child entity) 1.234 - { 1.235 - entity.Parent = null; 1.236 - } 1.237 - 1.238 - 1.239 - #endregion 1.240 - 1.241 - #region ctor 1.242 1.243 public Parent() 1.244 { 1.245 - _child = new EntitySet<Child>(Child_Attach, Child_Detach); 1.246 + Child = new EntitySet<Child>(entity => entity.Parent = this, entity => entity.Parent = null); 1.247 } 1.248 - 1.249 - #endregion 1.250 - 1.251 } 1.252 1.253 }
2.1 Binary file lib/DbLinq.PostgreSql.dll has changed
3.1 Binary file lib/DbLinq.PostgreSql.dll.mdb has changed
4.1 Binary file lib/DbLinq.dll has changed
5.1 Binary file lib/DbLinq.dll.mdb has changed
