public IInsertable <T> IgnoreColumns(Expression <Func <T, object> > columns) { var ignoreColumns = InsertBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Any(ig => ig.Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase))).ToList(); this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it => !ignoreColumns.Any(ig => ig.Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase))).ToList(); return(this); }
public virtual KeyValuePair <string, List <DbLiteParameter> > ToSql() { InsertBuilder.IsReturnIdentity = true; PreToSql(); AutoRemoveDataCache(); string sql = InsertBuilder.ToSqlString(); RestoreMapping(); return(new KeyValuePair <string, List <DbLiteParameter> >(sql, InsertBuilder.Parameters)); }
private string _ExecuteReturnIdentity() { InsertBuilder.IsReturnIdentity = true; PreToSql(); AutoRemoveDataCache(); string sql = InsertBuilder.ToSqlString(); RestoreMapping(); Before(sql); return(sql); }
public override async Task <long> ExecuteReturnBigIdentityAsync() { InsertBuilder.IsReturnIdentity = true; PreToSql(); string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault()); RestoreMapping(); var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0"); return(result); }
public override int ExecuteReturnIdentity() { InsertBuilder.IsReturnIdentity = true; PreToSql(); string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault()); RestoreMapping(); var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt(); return(result); }
public override long ExecuteReturnBigIdentity() { InsertBuilder.IsReturnIdentity = true; PreToSql(); string sql = InsertBuilder.ToSqlString(); RestoreMapping(); var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation; this.Context.Ado.IsDisableMasterSlaveSeparation = true; var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()); var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 :Convert.ToInt64(GetSeqValue(GetSeqName())); this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation; return(result); }
public static InsertBuilder GetInsertBuilder(ConnectionConfig currentConnectionConfig) { InsertBuilder result = CreateInstance <InsertBuilder>(GetClassName(currentConnectionConfig.DbType.ToString(), "InsertBuilder")); return(result); }