public void PersistEntity(Object entity) { DUtil.AttachObject(entity); Type entityBaseType = entity.GetType(); while (!entityBaseType.BaseType.Equals(typeof(Object))) { entityBaseType = entityBaseType.BaseType; } PropertyInfo propId = entityBaseType.GetProperty(entityBaseType.Name + "Id"); int id = (int)propId.GetValue(entity, null); if (id == 0) { DUtil.AddObject(entity); } else { DUtil.UpdateObject(entity); } }
public void AttachEntity(Object entity) { DUtil.AttachObject(entity); }