private int NewData(IConnectinContext cc, ObjectMapper om) { int result = 0; Insert insert = new Insert(om.Table); object value = null; if (om.ID != null) { if (om.ID.Value != null) { if (!om.ID.Value.AfterByUpdate) { om.ID.Value.Executing(cc, this, om.ID, om.Table); insert.AddField(om.ID.ColumnName, om.ID.Handler.Get(this)); } } else { insert.AddField(om.ID.ColumnName, om.ID.Handler.Get(this)); } } for (int i = 0; i < om.Properties.Count; i++) { PropertyMapper pm = om.Properties[i]; if (!EntityState._FieldState.ContainsKey(pm.Handler.Property.Name)) { if (pm.Value != null && !pm.Value.AfterByUpdate) { pm.Value.Executing(cc, this, pm, om.Table); } } value = pm.Handler.Get(this); if (EntityState._FieldState.ContainsKey(pm.Handler.Property.Name)) { if (pm.Cast != null) { value = pm.Cast.ToColumn(value, pm.Handler.Property.PropertyType, this); } insert.AddField(pm.ColumnName, value); } } result = insert.Execute(cc); if (om.ID != null && om.ID.Value != null && om.ID.Value.AfterByUpdate) { om.ID.Value.Executed(cc, this, om.ID, om.Table); } return(result); }
private int NewData(IConnectinContext cc, ObjectMapper om) { int result = 0; Insert insert = new Insert(om.Table); object value = null; if (om.ID != null) { if (om.ID.Value != null) { if (!om.ID.Value.AfterByUpdate) { om.ID.Value.Executing(cc, this, om.ID,om.Table); insert.AddField(om.ID.ColumnName, om.ID.Handler.Get(this)); } } else { insert.AddField(om.ID.ColumnName, om.ID.Handler.Get(this)); } } for(int i =0;i<om.Properties.Count;i++) { PropertyMapper pm = om.Properties[i]; if (!EntityState._FieldState.ContainsKey(pm.Handler.Property.Name)) { if (pm.Value != null && !pm.Value.AfterByUpdate) { pm.Value.Executing(cc, this, pm, om.Table); } } value = pm.Handler.Get(this); if (EntityState._FieldState.ContainsKey(pm.Handler.Property.Name)) { if (pm.Cast != null) { value = pm.Cast.ToColumn(value, pm.Handler.Property.PropertyType, this); } insert.AddField(pm.ColumnName, value); } } result=insert.Execute(cc); if (om.ID != null && om.ID.Value != null && om.ID.Value.AfterByUpdate) om.ID.Value.Executed(cc, this, om.ID,om.Table); return result; }