Changeset 2766 for branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess
- Timestamp:
- 02/08/10 19:14:58 (15 years ago)
- Location:
- branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStore.cs
r2742 r2766 55 55 56 56 public byte[] PluginFile(PluginDescription pluginDescription) { 57 return (from file in ctx.PluginPackages 58 where file.PluginId == pluginDescription.Id 59 select file.Data.ToArray()).Single(); 57 return GetExistingPlugin(pluginDescription.Name, pluginDescription.Version).PluginPackage.Data.ToArray(); 60 58 } 61 59 … … 63 61 try { 64 62 using (var transaction = new TransactionScope()) { 65 InsertOrUpdatePlugin(pluginDescription); 66 InsertOrUpdatePluginPackage(pluginDescription, pluginPackage); 63 Plugin pluginEntity = InsertOrUpdatePlugin(pluginDescription); 64 if (pluginEntity.PluginPackage == null) { 65 // insert 66 pluginEntity.PluginPackage = MakePluginPackage(pluginDescription, pluginPackage); 67 } else { 68 // update 69 pluginEntity.PluginPackage.Data = pluginPackage; 70 } 67 71 ctx.SubmitChanges(); 68 72 transaction.Complete(); … … 72 76 throw new ArgumentException("Something went wrong while trying to persist plugin", ex); 73 77 } 78 catch (InvalidOperationException ex) { 79 throw new ArgumentException("Something went wrong while trying to persist plugin", ex); 80 } 74 81 } 75 82 76 83 public void Persist(ProductDescription product) { 77 using (var transaction = new TransactionScope()) { 78 InsertOrUpdateProduct(product); 79 foreach (var plugin in product.Plugins) { 80 InsertOrUpdatePlugin(plugin); 84 try { 85 using (var transaction = new TransactionScope()) { 86 InsertOrUpdateProduct(product); 87 foreach (var plugin in product.Plugins) { 88 InsertOrUpdatePlugin(plugin); 89 } 90 ctx.SubmitChanges(); 91 transaction.Complete(); 81 92 } 82 ctx.SubmitChanges();83 transaction.Complete();84 93 } 85 } 86 87 private void InsertOrUpdatePluginPackage(PluginDescription pluginDescription, byte[] pluginPackage) { 88 var existing = from p in ctx.PluginPackages 89 where p.PluginId == pluginDescription.Id 90 select p; 91 92 if (existing.Count() == 0) { 93 ctx.PluginPackages.InsertOnSubmit(MakePluginPackage(pluginDescription, pluginPackage)); 94 } else { 95 var exisingPackage = existing.Single(); 96 exisingPackage.Data = pluginPackage; 94 catch (SqlException ex) { 95 throw new ArgumentException("Something went wrong while trying to persist product", ex); 96 } 97 catch (InvalidOperationException ex) { 98 throw new ArgumentException("Something went wrong while trying to persist product", ex); 97 99 } 98 100 } 99 101 100 102 private void InsertOrUpdateProduct(ProductDescription product) { 101 var existing =from p in ctx.Products102 where p.Id == product.Id103 select p;104 if (existing.Count() == 0) {105 var newEntity = MakeProductFromDescription(product); 106 ctx.Products.InsertOnSubmit(newEntity);107 // submit and write back db generated key103 var productEntity = (from p in ctx.Products 104 where p.Name == product.Name 105 where p.Version == product.Version.ToString() 106 select p).FirstOrDefault() ?? MakeProductFromDescription(product); 107 108 if (productEntity.Id <= 0) { 109 ctx.Products.InsertOnSubmit(productEntity); 108 110 ctx.SubmitChanges(); 109 product.Id = newEntity.Id;110 } else {111 var existingProduct = existing.Single();112 existingProduct.Name = product.Name;113 existingProduct.Version = product.Version.ToString();114 111 } 112 113 product.Id = productEntity.Id; 114 115 DeleteOldPlugins(productEntity); 116 115 117 foreach (var plugin in product.Plugins) { 116 InsertOrUpdateProductPlugin(plugin, product); 117 InsertOrUpdatePlugin(plugin); 118 var existingPlugin = GetExistingPlugin(plugin.Name, plugin.Version); 119 ProductPlugin prodPlugin = new ProductPlugin(); 120 prodPlugin.PluginId = existingPlugin.Id; 121 prodPlugin.ProductId = product.Id; 122 ctx.ProductPlugins.InsertOnSubmit(prodPlugin); 118 123 } 119 124 } 120 125 121 private void InsertOrUpdateProductPlugin(PluginDescription plugin, ProductDescription product) { 122 var existing = from pair in ctx.ProductPlugins 123 where pair.PluginId == plugin.Id 124 where pair.ProductId == product.Id 125 select pair; 126 if (existing.Count() != 0) { 127 var newEntity = new ProductPlugin(); 128 newEntity.PluginId = plugin.Id; 129 newEntity.ProductId = product.Id; 130 ctx.ProductPlugins.InsertOnSubmit(newEntity); 131 } 126 private void DeleteOldPlugins(Product productEntity) { 127 var oldPlugins = (from p in ctx.ProductPlugins 128 where p.ProductId == productEntity.Id 129 select p).ToList(); 130 ctx.ProductPlugins.DeleteAllOnSubmit(oldPlugins); 131 ctx.SubmitChanges(); 132 132 } 133 133 134 private void InsertOrUpdatePlugin(PluginDescription plugin) { 135 var existing = from p in ctx.Plugins 136 where p.Name == plugin.Name 137 where p.Version == plugin.Version.ToString() 138 select p; 139 if (existing.Count() == 0) { 140 var newEntity = MakePluginFromDescription(plugin); 141 ctx.Plugins.InsertOnSubmit(newEntity); 142 // submit and write back db generated key 134 private Plugin InsertOrUpdatePlugin(PluginDescription pluginDescription) { 135 var pluginEntity = (from p in ctx.Plugins 136 where p.Name == pluginDescription.Name 137 where p.Version == pluginDescription.Version.ToString() 138 select p).FirstOrDefault() ?? MakePluginFromDescription(pluginDescription); 139 140 if (pluginEntity.Id <= 0) { 141 ctx.Plugins.InsertOnSubmit(pluginEntity); 143 142 ctx.SubmitChanges(); 144 plugin.Id = newEntity.Id;145 } else {146 var existingPlugin = existing.Single();147 plugin.Id = existingPlugin.Id;148 143 } 149 foreach (var dependency in plugin.Dependencies) { 150 InsertOrUpdateDependency(plugin, dependency); 151 InsertOrUpdatePlugin(dependency); 144 pluginDescription.Id = pluginEntity.Id; 145 146 DeleteOldDependencies(pluginEntity); 147 148 foreach (var dependency in pluginDescription.Dependencies) { 149 var dependencyEntity = GetExistingPlugin(dependency.Name, dependency.Version); 150 Dependency d = new Dependency(); 151 d.PluginId = pluginDescription.Id; 152 d.DependencyId = dependencyEntity.Id; 153 ctx.Dependencies.InsertOnSubmit(d); 152 154 } 155 return pluginEntity; 156 153 157 } 154 158 155 private void InsertOrUpdateDependency(PluginDescription plugin, PluginDescription dependency) { 156 var existing = from pair in ctx.Dependencies 157 where pair.DependencyId == dependency.Id 158 where pair.PluginId == plugin.Id 159 select pair; 160 if (existing.Count() == 0) { 161 var newEntity = new Dependency(); 162 newEntity.PluginId = plugin.Id; 163 newEntity.DependencyId = dependency.Id; 164 ctx.Dependencies.InsertOnSubmit(newEntity); 165 } 159 private void DeleteOldDependencies(Plugin pluginEntity) { 160 var oldDependencies = (from dep in ctx.Dependencies 161 where dep.PluginId == pluginEntity.Id 162 select dep).ToList(); 163 164 ctx.Dependencies.DeleteAllOnSubmit(oldDependencies); 165 ctx.SubmitChanges(); 166 } 167 168 private Plugin GetExistingPlugin(string name, Version version) { 169 return (from p in ctx.Plugins 170 where p.Name == name 171 where p.Version == version.ToString() 172 select p).Single(); 166 173 } 167 174 -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml
r2742 r2766 6 6 <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 7 7 <Column Name="DependencyId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 8 <Association Name="Plugin_Dependency" Member="Plugin" ThisKey="DependencyId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />9 <Association Name="Plugin_Dependency1" Member="Plugin1" ThisKey="PluginId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />10 8 </Type> 11 9 </Table> 12 10 <Table Name="dbo.ProductPlugin" Member="ProductPlugins"> 13 11 <Type Name="ProductPlugin"> 14 <Column Name="ProductId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" /> 15 <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" /> 16 <Association Name="Plugin_ProductPlugin" Member="Plugin" ThisKey="PluginId" OtherKey="Id" Type="Plugin" IsForeignKey="true" /> 17 <Association Name="Product_ProductPlugin" Member="Product" ThisKey="ProductId" OtherKey="Id" Type="Product" IsForeignKey="true" /> 12 <Column Name="ProductId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 13 <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 18 14 </Type> 19 15 </Table> … … 23 19 <Column Name="Name" Type="System.String" DbType="NVarChar(300) NOT NULL" CanBeNull="false" /> 24 20 <Column Name="Version" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" /> 25 <Association Name="Plugin_Dependency" Member="Dependencies" ThisKey="Id" OtherKey="DependencyId" Type="Dependency" />26 <Association Name="Plugin_Dependency1" Member="Dependencies1" ThisKey="Id" OtherKey="PluginId" Type="Dependency" />27 <Association Name="Plugin_ProductPlugin" Member="ProductPlugins" ThisKey="Id" OtherKey="PluginId" Type="ProductPlugin" />28 21 <Association Name="Plugin_PluginPackage" Member="PluginPackage" ThisKey="Id" OtherKey="PluginId" Type="PluginPackage" Cardinality="One" /> 29 22 </Type> … … 39 32 <Table Name="dbo.Product" Member="Products"> 40 33 <Type Name="Product"> 41 <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL " IsPrimaryKey="true" CanBeNull="false" />34 <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> 42 35 <Column Name="Name" Type="System.String" DbType="NVarChar(300) NOT NULL" CanBeNull="false" /> 43 36 <Column Name="Version" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" /> 44 <Association Name="Product_ProductPlugin" Member="ProductPlugins" ThisKey="Id" OtherKey="ProductId" Type="ProductPlugin" />45 37 </Type> 46 38 </Table> -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml.layout
r2742 r2766 3 3 <DataContextMoniker Name="/PluginStoreClassesDataContext" /> 4 4 <nestedChildShapes> 5 <classShape Id=" b23b573a-6180-4641-ba9f-1bd9637deeff" absoluteBounds="3.5, 2.625, 2, 1.1939925130208335">5 <classShape Id="8eaeae9c-08a1-4be4-b58a-e3bf24f1961b" absoluteBounds="3.5, 2.625, 2, 1.1939925130208335"> 6 6 <DataClassMoniker Name="/PluginStoreClassesDataContext/Dependency" /> 7 7 <nestedChildShapes> 8 <elementListCompartment Id=" 0c1faa24-a5ab-4093-b697-127ff9dec797" absoluteBounds="3.515, 3.085, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />8 <elementListCompartment Id="c05168fe-dac9-499f-bf93-2ba4d92d3a81" absoluteBounds="3.515, 3.085, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 9 9 </nestedChildShapes> 10 10 </classShape> 11 <classShape Id=" 89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" absoluteBounds="3.5, 0.75, 2, 1.1939925130208335">11 <classShape Id="5f1b7d3a-0078-4834-a616-5cf8b1894803" absoluteBounds="3.5, 0.75, 2, 1.1939925130208335"> 12 12 <DataClassMoniker Name="/PluginStoreClassesDataContext/ProductPlugin" /> 13 13 <nestedChildShapes> 14 <elementListCompartment Id="6 eb3746b-0fec-4c95-8d53-03316bf2003a" absoluteBounds="3.515, 1.21, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />14 <elementListCompartment Id="66444473-2d73-4b22-9e6b-c440e2654f3f" absoluteBounds="3.515, 1.21, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 15 15 </nestedChildShapes> 16 16 </classShape> 17 <classShape Id=" c8a72752-dc21-43bd-8c14-169c06461993" absoluteBounds="0.75, 3.625, 2, 1.3862939453125">17 <classShape Id="37f2647d-7364-4f13-a869-2c8ebbc23260" absoluteBounds="0.75, 3.625, 2, 1.3862939453125"> 18 18 <DataClassMoniker Name="/PluginStoreClassesDataContext/Plugin" /> 19 19 <nestedChildShapes> 20 <elementListCompartment Id=" f85c30fe-b967-4cf5-ba0b-643fc01e8481" absoluteBounds="0.765, 4.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />20 <elementListCompartment Id="70f53f38-ca24-4ef6-8b0a-f3be78ad76c7" absoluteBounds="0.765, 4.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 21 21 </nestedChildShapes> 22 22 </classShape> 23 <classShape Id=" 3b48239e-4f4a-46d0-9962-fdc1173ba7bb" absoluteBounds="3.5, 6.625, 2, 1.3862939453125005">23 <classShape Id="6d0553e8-405a-4315-bc54-7af25f2a415d" absoluteBounds="3.5, 6.625, 2, 1.3862939453125005"> 24 24 <DataClassMoniker Name="/PluginStoreClassesDataContext/PluginPackage" /> 25 25 <nestedChildShapes> 26 <elementListCompartment Id=" e3a729ff-4cdf-44f7-b4da-0b4adc2bf9db" absoluteBounds="3.515, 7.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />26 <elementListCompartment Id="4bc7352f-2d30-4f49-897e-c741d0a60123" absoluteBounds="3.515, 7.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 27 27 </nestedChildShapes> 28 28 </classShape> 29 <classShape Id=" 2c5978b1-ebd4-4998-88f6-6f519a81c5b9" absoluteBounds="0.75, 1.5, 2, 1.3862939453125003">29 <classShape Id="c36a4ae4-62d6-4891-9389-afdef8241ad1" absoluteBounds="0.75, 1.5, 2, 1.3862939453125003"> 30 30 <DataClassMoniker Name="/PluginStoreClassesDataContext/Product" /> 31 31 <nestedChildShapes> 32 <elementListCompartment Id=" bfbec163-1dd5-435a-92e5-4d99b65b567f" absoluteBounds="0.765, 1.96, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />32 <elementListCompartment Id="ec5480b9-acee-4912-8ea6-a67dbb78a523" absoluteBounds="0.765, 1.96, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 33 33 </nestedChildShapes> 34 34 </classShape> 35 <associationConnector edgePoints="[(2.75 : 4.41514372916667); (3.88541416666667 : 4.41514372916667 : JumpStart); (4.05208083333333 : 4.41514372916667 : JumpEnd); (4.5 : 4.41514372916667); (4.5 : 3.81899251302083)]" fixedFrom="Algorithm" fixedTo="Algorithm">36 <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_Dependency" />37 <nodes>38 <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />39 <classShapeMoniker Id="b23b573a-6180-4641-ba9f-1bd9637deeff" />40 </nodes>41 </associationConnector>42 <associationConnector edgePoints="[(2.75 : 4.74447133723958); (3.9687475 : 4.74447133723958); (3.9687475 : 3.81899251302083)]" fixedFrom="Algorithm" fixedTo="Algorithm">43 <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_Dependency1" />44 <nodes>45 <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />46 <classShapeMoniker Id="b23b573a-6180-4641-ba9f-1bd9637deeff" />47 </nodes>48 </associationConnector>49 <associationConnector edgePoints="[(2.75 : 3.625); (3.125 : 3.25); (3.125 : 1.34699625651042); (3.5 : 1.34699625651042)]" fixedFrom="NotFixed" fixedTo="Algorithm">50 <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_ProductPlugin" />51 <nodes>52 <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />53 <classShapeMoniker Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" />54 </nodes>55 </associationConnector>56 35 <associationConnector edgePoints="[(1.75 : 5.0112939453125); (1.75 : 7.31814697265625); (3.5 : 7.31814697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 57 36 <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_PluginPackage" /> 58 37 <nodes> 59 <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" /> 60 <classShapeMoniker Id="3b48239e-4f4a-46d0-9962-fdc1173ba7bb" /> 61 </nodes> 62 </associationConnector> 63 <associationConnector edgePoints="[(2.75 : 1.72199625651042); (3.04166666666667 : 1.72199625651042 : JumpStart); (3.20833333333333 : 1.72199625651042 : JumpEnd); (3.5 : 1.72199625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 64 <AssociationMoniker Name="/PluginStoreClassesDataContext/Product/Product_ProductPlugin" /> 65 <nodes> 66 <classShapeMoniker Id="2c5978b1-ebd4-4998-88f6-6f519a81c5b9" /> 67 <classShapeMoniker Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" /> 38 <classShapeMoniker Id="37f2647d-7364-4f13-a869-2c8ebbc23260" /> 39 <classShapeMoniker Id="6d0553e8-405a-4315-bc54-7af25f2a415d" /> 68 40 </nodes> 69 41 </associationConnector> -
branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.designer.cs
r2742 r2766 34 34 partial void UpdateDependency(Dependency instance); 35 35 partial void DeleteDependency(Dependency instance); 36 partial void InsertProductPlugin(ProductPlugin instance); 37 partial void UpdateProductPlugin(ProductPlugin instance); 38 partial void DeleteProductPlugin(ProductPlugin instance); 36 39 partial void InsertPlugin(Plugin instance); 37 40 partial void UpdatePlugin(Plugin instance); … … 126 129 private long _DependencyId; 127 130 128 private EntityRef<Plugin> _Plugin;129 130 private EntityRef<Plugin> _Plugin1;131 132 131 #region Extensibility Method Definitions 133 132 partial void OnLoaded(); … … 142 141 public Dependency() 143 142 { 144 this._Plugin = default(EntityRef<Plugin>);145 this._Plugin1 = default(EntityRef<Plugin>);146 143 OnCreated(); 147 144 } … … 158 155 if ((this._PluginId != value)) 159 156 { 160 if (this._Plugin1.HasLoadedOrAssignedValue)161 {162 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();163 }164 157 this.OnPluginIdChanging(value); 165 158 this.SendPropertyChanging(); … … 182 175 if ((this._DependencyId != value)) 183 176 { 184 if (this._Plugin.HasLoadedOrAssignedValue)185 {186 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();187 }188 177 this.OnDependencyIdChanging(value); 189 178 this.SendPropertyChanging(); … … 195 184 } 196 185 197 [Association(Name="Plugin_Dependency", Storage="_Plugin", ThisKey="DependencyId", OtherKey="Id", IsForeignKey=true)]198 public Plugin Plugin199 {200 get201 {202 return this._Plugin.Entity;203 }204 set205 {206 Plugin previousValue = this._Plugin.Entity;207 if (((previousValue != value)208 || (this._Plugin.HasLoadedOrAssignedValue == false)))209 {210 this.SendPropertyChanging();211 if ((previousValue != null))212 {213 this._Plugin.Entity = null;214 previousValue.Dependencies.Remove(this);215 }216 this._Plugin.Entity = value;217 if ((value != null))218 {219 value.Dependencies.Add(this);220 this._DependencyId = value.Id;221 }222 else223 {224 this._DependencyId = default(long);225 }226 this.SendPropertyChanged("Plugin");227 }228 }229 }230 231 [Association(Name="Plugin_Dependency1", Storage="_Plugin1", ThisKey="PluginId", OtherKey="Id", IsForeignKey=true)]232 public Plugin Plugin1233 {234 get235 {236 return this._Plugin1.Entity;237 }238 set239 {240 Plugin previousValue = this._Plugin1.Entity;241 if (((previousValue != value)242 || (this._Plugin1.HasLoadedOrAssignedValue == false)))243 {244 this.SendPropertyChanging();245 if ((previousValue != null))246 {247 this._Plugin1.Entity = null;248 previousValue.Dependencies1.Remove(this);249 }250 this._Plugin1.Entity = value;251 if ((value != null))252 {253 value.Dependencies1.Add(this);254 this._PluginId = value.Id;255 }256 else257 {258 this._PluginId = default(long);259 }260 this.SendPropertyChanged("Plugin1");261 }262 }263 }264 265 186 public event PropertyChangingEventHandler PropertyChanging; 266 187 … … 285 206 286 207 [Table(Name="dbo.ProductPlugin")] 287 public partial class ProductPlugin 208 public partial class ProductPlugin : INotifyPropertyChanging, INotifyPropertyChanged 288 209 { 289 210 211 private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); 212 290 213 private long _ProductId; 291 214 292 215 private long _PluginId; 293 216 217 #region Extensibility Method Definitions 218 partial void OnLoaded(); 219 partial void OnValidate(System.Data.Linq.ChangeAction action); 220 partial void OnCreated(); 221 partial void OnProductIdChanging(long value); 222 partial void OnProductIdChanged(); 223 partial void OnPluginIdChanging(long value); 224 partial void OnPluginIdChanged(); 225 #endregion 226 294 227 public ProductPlugin() 295 228 { 296 } 297 298 [Column(Storage="_ProductId", DbType="BigInt NOT NULL")] 229 OnCreated(); 230 } 231 232 [Column(Storage="_ProductId", DbType="BigInt NOT NULL", IsPrimaryKey=true)] 299 233 public long ProductId 300 234 { … … 307 241 if ((this._ProductId != value)) 308 242 { 243 this.OnProductIdChanging(value); 244 this.SendPropertyChanging(); 309 245 this._ProductId = value; 310 } 311 } 312 } 313 314 [Column(Storage="_PluginId", DbType="BigInt NOT NULL")] 246 this.SendPropertyChanged("ProductId"); 247 this.OnProductIdChanged(); 248 } 249 } 250 } 251 252 [Column(Storage="_PluginId", DbType="BigInt NOT NULL", IsPrimaryKey=true)] 315 253 public long PluginId 316 254 { … … 323 261 if ((this._PluginId != value)) 324 262 { 263 this.OnPluginIdChanging(value); 264 this.SendPropertyChanging(); 325 265 this._PluginId = value; 326 } 266 this.SendPropertyChanged("PluginId"); 267 this.OnPluginIdChanged(); 268 } 269 } 270 } 271 272 public event PropertyChangingEventHandler PropertyChanging; 273 274 public event PropertyChangedEventHandler PropertyChanged; 275 276 protected virtual void SendPropertyChanging() 277 { 278 if ((this.PropertyChanging != null)) 279 { 280 this.PropertyChanging(this, emptyChangingEventArgs); 281 } 282 } 283 284 protected virtual void SendPropertyChanged(String propertyName) 285 { 286 if ((this.PropertyChanged != null)) 287 { 288 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 327 289 } 328 290 } … … 340 302 341 303 private string _Version; 342 343 private EntitySet<Dependency> _Dependencies;344 345 private EntitySet<Dependency> _Dependencies1;346 304 347 305 private EntityRef<PluginPackage> _PluginPackage; … … 361 319 public Plugin() 362 320 { 363 this._Dependencies = new EntitySet<Dependency>(new Action<Dependency>(this.attach_Dependencies), new Action<Dependency>(this.detach_Dependencies));364 this._Dependencies1 = new EntitySet<Dependency>(new Action<Dependency>(this.attach_Dependencies1), new Action<Dependency>(this.detach_Dependencies1));365 321 this._PluginPackage = default(EntityRef<PluginPackage>); 366 322 OnCreated(); … … 424 380 this.OnVersionChanged(); 425 381 } 426 }427 }428 429 [Association(Name="Plugin_Dependency", Storage="_Dependencies", ThisKey="Id", OtherKey="DependencyId")]430 public EntitySet<Dependency> Dependencies431 {432 get433 {434 return this._Dependencies;435 }436 set437 {438 this._Dependencies.Assign(value);439 }440 }441 442 [Association(Name="Plugin_Dependency1", Storage="_Dependencies1", ThisKey="Id", OtherKey="PluginId")]443 public EntitySet<Dependency> Dependencies1444 {445 get446 {447 return this._Dependencies1;448 }449 set450 {451 this._Dependencies1.Assign(value);452 382 } 453 383 } … … 500 430 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 501 431 } 502 }503 504 private void attach_Dependencies(Dependency entity)505 {506 this.SendPropertyChanging();507 entity.Plugin = this;508 }509 510 private void detach_Dependencies(Dependency entity)511 {512 this.SendPropertyChanging();513 entity.Plugin = null;514 }515 516 private void attach_Dependencies1(Dependency entity)517 {518 this.SendPropertyChanging();519 entity.Plugin1 = this;520 }521 522 private void detach_Dependencies1(Dependency entity)523 {524 this.SendPropertyChanging();525 entity.Plugin1 = null;526 432 } 527 433 } … … 707 613 } 708 614 709 [Column(Storage="_Id", DbType="BigInt NOT NULL", IsPrimaryKey=true)]615 [Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] 710 616 public long Id 711 617 {
Note: See TracChangeset
for help on using the changeset viewer.