public EntityParameters <SqlParameter> GetUpdateParameters(object entity) { EntityUpdateParameters = EntityUpdateParameters ?? CreateEntityParameters(entity, false); EntityUpdateParameters.FillParameters(entity, FillInsertParameters); return(EntityUpdateParameters); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <param name="createAction"></param> /// <typeparam name="TEntity"></typeparam> /// <returns></returns> public static EntityParameters <TDbParameter> Create <TEntity>(TEntity entity , Action <TEntity, IDictionary <PropertyInfo, TDbParameter>, IDictionary <PropertyInfo, TDbParameter>, bool> createAction , bool checkForIdentity) { var entityParameters = new EntityParameters <TDbParameter>(); createAction.Invoke(entity, entityParameters.DataParametersDictionary, entityParameters.OutParametersDictionary, checkForIdentity); return(entityParameters); }
//public List<IDataParameter> DataParameters { get; set; } /// <summary> /// Create parameters from object properties /// </summary> /// <param name="parametersType"></param> /// <returns></returns> public EntityParameters <SqlParameter> CreateEntityParameters(object entity, bool checkForIdentityColumn) { var entityParameters = EntityParameters <SqlParameter> .Create(entity, (o, dataParameters, outParamsDictionary, checkForIdentity) => { var entityType = entity.GetType(); var propertiesForDataParams = entityType.GetTypeInfo().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Default); foreach (var propertyInfo in propertiesForDataParams) { CreateDataParameter(propertyInfo, dataParameters, outParamsDictionary, checkForIdentity); } }, checkForIdentityColumn); return(entityParameters); }
/// <summary> /// Clear all DbParamters /// </summary> public void ClearDbParameters() { EntityInsertParameters = null; EntityUpdateParameters = null; }