dblinq-experiment
changeset 1:248fb7a05b8d
Got something functional by using generated code
| author | Emanuele Aina <em@nerd.ocracy.org> |
|---|---|
| date | Fri Sep 04 14:50:39 2009 +0200 (10 months ago) |
| parents | 62f9a07e8d01 |
| children | 9c9c6be70123 |
| files | Experiment.cs db/Db.cs lib/DbLinq.PostgreSql.dll lib/DbLinq.PostgreSql.dll.mdb lib/DbLinq.dll lib/DbLinq.dll.mdb |
line diff
1.1 --- a/Experiment.cs Thu Sep 03 16:17:40 2009 +0200 1.2 +++ b/Experiment.cs Fri Sep 04 14:50:39 2009 +0200 1.3 @@ -20,10 +20,11 @@ 1.4 var numbers = new int[]{ 1, 2, 3 }; 1.5 foreach(var i in numbers) { 1.6 var child = new Child() { Number = i, Parent = parent }; 1.7 - db.GetTable<Child>().InsertOnSubmit(child); 1.8 + //db.GetTable<Child>().InsertOnSubmit(child); 1.9 } 1.10 db.SubmitChanges(); 1.11 } 1.12 + Console.WriteLine("Done."); 1.13 } 1.14 1.15 }
2.1 --- a/db/Db.cs Thu Sep 03 16:17:40 2009 +0200 2.2 +++ b/db/Db.cs Fri Sep 04 14:50:39 2009 +0200 2.3 @@ -1,47 +1,256 @@ 2.4 -using System; 2.5 -using System.Diagnostics; 2.6 -using System.Collections.Generic; 2.7 -using System.Text; 2.8 -using System.Linq; 2.9 -//using System.Data.Linq; 2.10 -using System.Data.Linq.Mapping; 2.11 -using System.Reflection; 2.12 -using DbLinq.Data.Linq; 2.13 -using DbLinq.PostgreSql; 2.14 - 2.15 -namespace Experiment.Db 2.16 -{ 2.17 - 2.18 - [Table(Name = "parent")] 2.19 - public partial class Parent 2.20 - { 2.21 - public Parent() { } 2.22 - 2.23 - [Column(Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false, Expression = "nextval('parent_id_seq')")] 2.24 - public int Id { get; set; } 2.25 - 2.26 - [Column(Name = "name", DbType = "text")] 2.27 - public string Name { get; set; } 2.28 - 2.29 - [Association(OtherKey = "ParentId", Name = "child_parent_fkey", IsForeignKey = true)] 2.30 - public System.Data.Linq.EntitySet<Child> Children { get; set; } 2.31 - } 2.32 - 2.33 - [Table(Name = "child")] 2.34 - public partial class Child 2.35 - { 2.36 - public Child() { } 2.37 - 2.38 - [Column(Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false, Expression = "nextval('child_id_seq')")] 2.39 - public int Id { get; set; } 2.40 - 2.41 - [Column(Name = "number", DbType = "integer(32,0)")] 2.42 - public int Number { get; set; } 2.43 - 2.44 - [Column(Name = "parent", DbType = "integer(32,0)")] 2.45 - public int ParentId { get; set; } 2.46 - 2.47 - [Association(ThisKey = "ParentId", Name = "child_parent_fkey")] 2.48 - public Parent Parent { get; set; } 2.49 - } 2.50 -} 2.51 +using System; 2.52 +using System.Data; 2.53 +using System.Data.Linq.Mapping; 2.54 +using System.Diagnostics; 2.55 +using System.Reflection; 2.56 +using DbLinq.Data.Linq; 2.57 +using DbLinq.Vendor; 2.58 +using System.ComponentModel; 2.59 + 2.60 +namespace Experiment.Db 2.61 +{ 2.62 +[Table(Name = "public.child")] 2.63 +public partial class Child : INotifyPropertyChanged 2.64 +{ 2.65 + #region INotifyPropertyChanged handling 2.66 + 2.67 + public event PropertyChangedEventHandler PropertyChanged; 2.68 + 2.69 + protected virtual void OnPropertyChanged(string propertyName) 2.70 + { 2.71 + if (PropertyChanged != null) 2.72 + { 2.73 + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 2.74 + } 2.75 + } 2.76 + 2.77 + #endregion 2.78 + 2.79 + #region int Id 2.80 + 2.81 + public int _id; 2.82 + [DebuggerNonUserCode] 2.83 + [Column(Storage = "_id", Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.Never, Expression = "nextval('child_id_seq')")] 2.84 + public int Id 2.85 + { 2.86 + get 2.87 + { 2.88 + return _id; 2.89 + } 2.90 + set 2.91 + { 2.92 + if (value != _id) 2.93 + { 2.94 + _id = value; 2.95 + OnPropertyChanged("Id"); 2.96 + } 2.97 + } 2.98 + } 2.99 + 2.100 + #endregion 2.101 + 2.102 + #region int? Number 2.103 + 2.104 + public int? _number; 2.105 + [DebuggerNonUserCode] 2.106 + [Column(Storage = "_number", Name = "number", DbType = "integer(32,0)", AutoSync = AutoSync.Never, CanBeNull = true)] 2.107 + public int? Number 2.108 + { 2.109 + get 2.110 + { 2.111 + return _number; 2.112 + } 2.113 + set 2.114 + { 2.115 + if (value != _number) 2.116 + { 2.117 + _number = value; 2.118 + OnPropertyChanged("Number"); 2.119 + } 2.120 + } 2.121 + } 2.122 + 2.123 + #endregion 2.124 + 2.125 + #region int? Parent 2.126 + 2.127 + public int? _parentId; 2.128 + [DebuggerNonUserCode] 2.129 + [Column(Storage = "_parentId", Name = "parent", DbType = "integer(32,0)", AutoSync = AutoSync.Never, CanBeNull = true)] 2.130 + public int? ParentId 2.131 + { 2.132 + get 2.133 + { 2.134 + return _parentId; 2.135 + } 2.136 + set 2.137 + { 2.138 + if (value != _parentId) 2.139 + { 2.140 + _parentId = value; 2.141 + OnPropertyChanged("ParentId"); 2.142 + } 2.143 + } 2.144 + } 2.145 + 2.146 + #endregion 2.147 + 2.148 + #region Parents 2.149 + 2.150 + public EntityRef<Parent> _parent; 2.151 + [Association(Storage = "_parent", OtherKey = "Id", ThisKey = "ParentId", Name = "child_parent_fkey", IsForeignKey = true)] 2.152 + [DebuggerNonUserCode] 2.153 + public Parent Parent 2.154 + { 2.155 + get 2.156 + { 2.157 + return _parent.Entity; 2.158 + } 2.159 + set 2.160 + { 2.161 + if (value != _parent.Entity) 2.162 + { 2.163 + if (_parent.Entity != null) 2.164 + { 2.165 + var previousParent = _parent.Entity; 2.166 + _parent.Entity = null; 2.167 + previousParent.Child.Remove(this); 2.168 + } 2.169 + _parent.Entity = value; 2.170 + if (value != null) 2.171 + { 2.172 + value.Child.Add(this); 2.173 + _parentId = value.Id; 2.174 + } 2.175 + else 2.176 + { 2.177 + _parentId = null; 2.178 + } 2.179 + } 2.180 + } 2.181 + } 2.182 + 2.183 + 2.184 + #endregion 2.185 + 2.186 + #region ctor 2.187 + 2.188 + public Child() 2.189 + { 2.190 + _parent = new EntityRef<Parent>(); 2.191 + } 2.192 + 2.193 + #endregion 2.194 + 2.195 +} 2.196 + 2.197 +[Table(Name = "public.parent")] 2.198 +public partial class Parent : INotifyPropertyChanged 2.199 +{ 2.200 + #region INotifyPropertyChanged handling 2.201 + 2.202 + public event PropertyChangedEventHandler PropertyChanged; 2.203 + 2.204 + protected virtual void OnPropertyChanged(string propertyName) 2.205 + { 2.206 + if (PropertyChanged != null) 2.207 + { 2.208 + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 2.209 + } 2.210 + } 2.211 + 2.212 + #endregion 2.213 + 2.214 + #region int Id 2.215 + 2.216 + public int _id; 2.217 + [DebuggerNonUserCode] 2.218 + [Column(Storage = "_id", Name = "id", DbType = "integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.Never, Expression = "nextval('parent_id_seq')")] 2.219 + public int Id 2.220 + { 2.221 + get 2.222 + { 2.223 + return _id; 2.224 + } 2.225 + set 2.226 + { 2.227 + if (value != _id) 2.228 + { 2.229 + _id = value; 2.230 + OnPropertyChanged("Id"); 2.231 + } 2.232 + } 2.233 + } 2.234 + 2.235 + #endregion 2.236 + 2.237 + #region string Name 2.238 + 2.239 + public string _name; 2.240 + [DebuggerNonUserCode] 2.241 + [Column(Storage = "_name", Name = "name", DbType = "text", AutoSync = AutoSync.Never, CanBeNull = true)] 2.242 + public string Name 2.243 + { 2.244 + get 2.245 + { 2.246 + return _name; 2.247 + } 2.248 + set 2.249 + { 2.250 + if (value != _name) 2.251 + { 2.252 + _name = value; 2.253 + OnPropertyChanged("Name"); 2.254 + } 2.255 + } 2.256 + } 2.257 + 2.258 + #endregion 2.259 + 2.260 + #region Children 2.261 + 2.262 + public EntitySet<Child> _child; 2.263 + [Association(Storage = "_child", OtherKey = "ParentId", ThisKey = "Id", Name = "child_parent_fkey")] 2.264 + [DebuggerNonUserCode] 2.265 + public EntitySet<Child> Child 2.266 + { 2.267 + get 2.268 + { 2.269 + return _child; 2.270 + } 2.271 + set 2.272 + { 2.273 + _child = value; 2.274 + } 2.275 + } 2.276 + 2.277 + 2.278 + #endregion 2.279 + 2.280 + #region Attachement handlers 2.281 + 2.282 + public void Child_Attach(Child entity) 2.283 + { 2.284 + entity.Parent = this; 2.285 + } 2.286 + 2.287 + public void Child_Detach(Child entity) 2.288 + { 2.289 + entity.Parent = null; 2.290 + } 2.291 + 2.292 + 2.293 + #endregion 2.294 + 2.295 + #region ctor 2.296 + 2.297 + public Parent() 2.298 + { 2.299 + _child = new EntitySet<Child>(Child_Attach, Child_Detach); 2.300 + } 2.301 + 2.302 + #endregion 2.303 + 2.304 +} 2.305 + 2.306 +}
3.1 Binary file lib/DbLinq.PostgreSql.dll has changed
4.1 Binary file lib/DbLinq.PostgreSql.dll.mdb has changed
5.1 Binary file lib/DbLinq.dll has changed
6.1 Binary file lib/DbLinq.dll.mdb has changed
