public RowAdapter NewRowAdapter(Selector columnNames) { RowObjectAdapter d = new RowObjectAdapter(this, columnNames) { InsertIdentityOn = this.insertIdentityOn }; return(d); }
/// <summary> /// this dpo Compares to the Reocrd in the SQL Server /// </summary> public bool Changed(params string[] ignoredColumns) { RowObjectAdapter d = new RowObjectAdapter(this); d.Apply(); bool exists = d.Load(); if (!exists) { return(true); } return(!d.Row.EqualTo(this.Row, ignoredColumns)); }
public virtual DataRow Load() { RowObjectAdapter d = new RowObjectAdapter(this); d.Apply(); exists = d.Load(); FillObject(d.Row); //RowLoaded(d.Row); AfterLoaded?.Invoke(this, new DataRowChangeEventArgs(d.Row, DataRowAction.Nothing)); return(d.Row); }
public virtual bool Delete() { RowObjectAdapter d = new RowObjectAdapter(this); d.Apply(); //check 1..many table dependency foreach (PropertyInfo propertyInfo in this.columnProperties) { AssociationAttribute association = Reflex.GetAssociationAttribute(propertyInfo); if (association == null) { continue; } if (!propertyInfo.PropertyType.IsGenericType) { continue; } IDPCollection collection = (IDPCollection)propertyInfo.GetValue(this, null); if (collection.Count == 0) { continue; } Type[] typeParameters = propertyInfo.PropertyType.GetGenericArguments(); if (typeParameters.Length == 1 && typeParameters[0].IsSubclassOf(typeof(PersistentObject))) { throw new ApplicationException(string.Format( "Error: data persistent object on Table {0} cannot be deleted because Table {1} depends on it.", TableName, collection.TableName)); } } d.RowChanged += RowChanged; return(d.Delete()); }
private DataRow save(Selector columnNames, SaveMode mode) { RowObjectAdapter d = new RowObjectAdapter(this, columnNames); d.Apply(); d.InsertIdentityOn = this.insertIdentityOn; d.ValueChangedHandler = ValueChanged; d.RowChanged += RowChanged; if (BeforeSaving != null) { d.RowChanged += BeforeSaving; } switch (mode) { case SaveMode.Insert: d.Insert(); break; case SaveMode.Update: d.Update(); break; case SaveMode.Save: d.Save(); break; case SaveMode.Validate: d.Validate(); break; } FillIdentity(d.Row); //because of Identity retrieved return(d.Row); }