public static void ParameterStyle(this ITransactionContext transaction, QueryParameterStyle value) { if (value == QueryParameterStyle.Default) return; var styleString = value.ToString(); transaction.SetStringVariable(TransactionSettingKeys.ParameterStyle, styleString); }
public static void ParameterStyle(this ITransactionContext transaction, QueryParameterStyle value) { if (value == QueryParameterStyle.Default) { return; } var styleString = value.ToString(); transaction.SetStringVariable(TransactionSettingKeys.ParameterStyle, styleString); }
internal void ChangeStyle(QueryParameterStyle style) { if (ParameterStyle != QueryParameterStyle.Default) { throw new InvalidOperationException(); } if (style == QueryParameterStyle.Default) { throw new ArgumentException(); } ParameterStyle = style; }
private void InitToDefault() { host = DefaultHost; port = DefaultPort; database = DefaultDatabase; userName = DefaultUserName; password = DefaultPassword; schema = DefaultSchema; path = DefaultPath; paramStyle = DefaultParameterStyle; verboseColumnNames = DefaultVerboseColumnName; persistSecurityInfo = DefaultPersistSecurityInfo; rowCacheSize = DefaultRowCacheSize; maxCacheSize = DefaultMaxCacheSize; queryTimeout = DefaultQueryTimeout; ignoreCase = DefaultIgnoreIdentifiersCase; create = DefaultCreate; bootOrCreate = DefaultBootOrCreate; strictGetValue = DefaultStrictGetValue; fetchSize = DefaultFetchSize; maxFetchSize = DefaultMaxFetchSize; autoCommit = DefaultAutoCommit; enlist = DefaultEnlist; }
protected void SetParameterStyle(QueryParameterStyle parameterStyle) { QueryContext.ParameterStyle(parameterStyle); }
public static void ParameterStyle(this IQueryContext context, QueryParameterStyle value) { context.Session.ParameterStyle(value); }
protected IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable <QueryParameter> parameters, QueryParameterStyle parameterStyle) { // Where Query result eventually resides. int resultId = -1; // For each StreamableObject in the query object, translate it to a // IRef object that presumably has been pre-pushed onto the server from // the client. // Evaluate the sql Query. var query = new SqlQuery(text, parameterStyle); if (parameters != null) { foreach (var p in parameters) { var c = p.SqlType.TypeCode; switch (c) { case SqlTypeCode.Blob: case SqlTypeCode.Clob: case SqlTypeCode.LongVarBinary: case SqlTypeCode.LongVarChar: case SqlTypeCode.VarBinary: throw new NotImplementedException("TODO: Download the Large-Objects and replace with a reference"); default: query.Parameters.Add(p); break; } } } var stopwatch = new Stopwatch(); stopwatch.Start(); var results = context.ExecuteQuery(query); var responses = new IQueryResponse[results.Length]; int j = 0; foreach (var result in results) { QueryResult queryResult; try { if (result.Type == StatementResultType.Exception) { throw result.Error; } queryResult = new QueryResult(query, result, context.AutoCommit()); resultId = AddResult(queryResult); } catch (Exception) { if (resultId != -1) { DisposeResult(resultId); } throw; } var taken = stopwatch.ElapsedMilliseconds; // Return the Query response responses[j] = new QueryResponse(resultId, queryResult, (int)taken, ""); j++; } stopwatch.Stop(); return(responses); }
protected void SetParameterStyle(QueryParameterStyle parameterStyle) { this.parameterStyle = parameterStyle; }
public SqlQuery(string text, QueryParameterStyle parameterStyle) { Text = text; ParameterStyle = parameterStyle; Parameters = new QueryParameterCollection(this); }
public static void ParameterStyle(this ISession session, QueryParameterStyle value) { session.Transaction.ParameterStyle(value); }
public static void ParameterStyle(this IQueryContext context, QueryParameterStyle value) { context.SessionContext.TransactionContext.ParameterStyle(value); }
public QueryPreparer(SqlQuery query, QueryParameterStyle paramStyle) { this.query = query; this.paramStyle = paramStyle; }
public static void ParameterStyle(this IQuery query, QueryParameterStyle value) { query.Context.ParameterStyle(value); }
private void SetValue(string key, object value) { if (key == null) throw new ArgumentNullException("key"); key = MappKey(key); switch (key) { case HostKey: { if (value == null) { host = DefaultHost; base.Remove(key); } else { Host = value.ToString(); } break; } case PortKey: if (value == null) { port = DefaultPort; base.Remove(key); } else { Port = ToInt32(value); } break; case DatabaseKey: if (value == null) { database = DefaultDatabase; base.Remove(key); } else { Database = value.ToString(); } break; case SchemaKey: if (value == null) { schema = DefaultSchema; base.Remove(key); } else { Schema = value.ToString(); } break; case PathKey: if (value == null) { path = DefaultPath; base.Remove(key); } else { Path = value.ToString(); } break; case UserNameKey: if (value == null) { userName = DefaultUserName; base.Remove(key); } else { UserName = value.ToString(); } break; case PasswordKey: if (value == null) { password = DefaultPassword; base.Remove(key); } else { Password = value.ToString(); } break; case PersistSecurityInfoKey: if (value == null) { persistSecurityInfo = DefaultPersistSecurityInfo; base.Remove(key); } else { PersistSecurityInfo = ToBoolean(value); } break; case VerboseColumnNamesKey: if (value == null) { verboseColumnNames = DefaultVerboseColumnName; base.Remove(key); } else { VerboseColumnNames = ToBoolean(value); } break; case ParameterStyleKey: if (value == null) { paramStyle = DefaultParameterStyle; base.Remove(key); } else if (value is string) { ParameterStyle = (QueryParameterStyle)Enum.Parse(typeof(QueryParameterStyle), (string)value, true); } else if (value is int || value is QueryParameterStyle) { ParameterStyle = (QueryParameterStyle)value; } break; case RowCacheSizeKey: if (value == null) { rowCacheSize = DefaultRowCacheSize; base.Remove(key); } else { RowCacheSize = ToInt32(value); } break; case MaxCacheSizeKey: if (value == null) { maxCacheSize = DefaultMaxCacheSize; base.Remove(key); } else { MaxCacheSize = ToInt32(value); } break; case QueryTimeoutKey: if (value == null) { queryTimeout = DefaultQueryTimeout; base.Remove(key); } else { QueryTimeout = ToInt32(value); } break; case IgnoreIdentifiersCaseKey: if (value == null) { ignoreCase = DefaultIgnoreIdentifiersCase; base.Remove(key); } else { IgnoreIdentifiersCase = ToBoolean(value); } break; case CreateKey: if (value == null) { create = DefaultCreate; base.Remove(key); } else { Create = ToBoolean(value); } break; case BootOrCreateKey: if (value == null) { bootOrCreate = DefaultBootOrCreate; base.Remove(key); } else { BootOrCreate = ToBoolean(value); } break; case StrictGetValueKey: if (value == null) { strictGetValue = DefaultStrictGetValue; base.Remove(key); } else { StrictGetValue = ToBoolean(value); } break; case "DataSource": if (value == null) { } else { string s = value.ToString(); int index = s.IndexOf(':'); if (index != -1) { string sPort = s.Substring(index + 1); Host = s.Substring(0, index); Port = Int32.Parse(sPort); } else { Host = s; } } break; case FetchSizeKey: if (value == null) { fetchSize = DefaultFetchSize; base.Remove(FetchSizeKey); } else { FetchSize = ToInt32(value); } break; case MaxFetchSizeKey: if (value == null) { maxFetchSize = DefaultMaxFetchSize; base.Remove(MaxFetchSizeKey); } else { MaxFetchSize = ToInt32(value); } break; case AutoCommitKey: if (value == null) { autoCommit = DefaultAutoCommit; base.Remove(AutoCommitKey); } else { AutoCommit = ToBoolean(value); } break; case EnlistKey: if (value == null) { enlist = DefaultEnlist; base.Remove(EnlistKey); } else { Enlist = ToBoolean(value); } break; default: //TODO: support additional parameters for Boot/Create process... throw new ArgumentException("Key '" + key + "' is not recognized.", "key"); } }
public static void ParameterStyle(this ITransaction transaction, QueryParameterStyle value) { transaction.Context.ParameterStyle(value); }
private void SetValue(string key, object value) { if (key == null) { throw new ArgumentNullException("key"); } key = MappKey(key); switch (key) { case HostKey: { if (value == null) { host = DefaultHost; base.Remove(key); } else { Host = value.ToString(); } break; } case PortKey: if (value == null) { port = DefaultPort; base.Remove(key); } else { Port = ToInt32(value); } break; case DatabaseKey: if (value == null) { database = DefaultDatabase; base.Remove(key); } else { Database = value.ToString(); } break; case SchemaKey: if (value == null) { schema = DefaultSchema; base.Remove(key); } else { Schema = value.ToString(); } break; case PathKey: if (value == null) { path = DefaultPath; base.Remove(key); } else { Path = value.ToString(); } break; case UserNameKey: if (value == null) { userName = DefaultUserName; base.Remove(key); } else { UserName = value.ToString(); } break; case PasswordKey: if (value == null) { password = DefaultPassword; base.Remove(key); } else { Password = value.ToString(); } break; case PersistSecurityInfoKey: if (value == null) { persistSecurityInfo = DefaultPersistSecurityInfo; base.Remove(key); } else { PersistSecurityInfo = ToBoolean(value); } break; case VerboseColumnNamesKey: if (value == null) { verboseColumnNames = DefaultVerboseColumnName; base.Remove(key); } else { VerboseColumnNames = ToBoolean(value); } break; case ParameterStyleKey: if (value == null) { paramStyle = DefaultParameterStyle; base.Remove(key); } else if (value is string) { ParameterStyle = (QueryParameterStyle)Enum.Parse(typeof(QueryParameterStyle), (string)value, true); } else if (value is int || value is QueryParameterStyle) { ParameterStyle = (QueryParameterStyle)value; } break; case RowCacheSizeKey: if (value == null) { rowCacheSize = DefaultRowCacheSize; base.Remove(key); } else { RowCacheSize = ToInt32(value); } break; case MaxCacheSizeKey: if (value == null) { maxCacheSize = DefaultMaxCacheSize; base.Remove(key); } else { MaxCacheSize = ToInt32(value); } break; case QueryTimeoutKey: if (value == null) { queryTimeout = DefaultQueryTimeout; base.Remove(key); } else { QueryTimeout = ToInt32(value); } break; case IgnoreIdentifiersCaseKey: if (value == null) { ignoreCase = DefaultIgnoreIdentifiersCase; base.Remove(key); } else { IgnoreIdentifiersCase = ToBoolean(value); } break; case CreateKey: if (value == null) { create = DefaultCreate; base.Remove(key); } else { Create = ToBoolean(value); } break; case BootOrCreateKey: if (value == null) { bootOrCreate = DefaultBootOrCreate; base.Remove(key); } else { BootOrCreate = ToBoolean(value); } break; case StrictGetValueKey: if (value == null) { strictGetValue = DefaultStrictGetValue; base.Remove(key); } else { StrictGetValue = ToBoolean(value); } break; case "DataSource": if (value == null) { } else { string s = value.ToString(); int index = s.IndexOf(':'); if (index != -1) { string sPort = s.Substring(index + 1); Host = s.Substring(0, index); Port = Int32.Parse(sPort); } else { Host = s; } } break; case FetchSizeKey: if (value == null) { fetchSize = DefaultFetchSize; base.Remove(FetchSizeKey); } else { FetchSize = ToInt32(value); } break; case MaxFetchSizeKey: if (value == null) { maxFetchSize = DefaultMaxFetchSize; base.Remove(MaxFetchSizeKey); } else { MaxFetchSize = ToInt32(value); } break; case AutoCommitKey: if (value == null) { autoCommit = DefaultAutoCommit; base.Remove(AutoCommitKey); } else { AutoCommit = ToBoolean(value); } break; case EnlistKey: if (value == null) { enlist = DefaultEnlist; base.Remove(EnlistKey); } else { Enlist = ToBoolean(value); } break; default: //TODO: support additional parameters for Boot/Create process... throw new ArgumentException("Key '" + key + "' is not recognized.", "key"); } }
protected IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters, QueryParameterStyle parameterStyle) { // Where Query result eventually resides. int resultId = -1; // For each StreamableObject in the query object, translate it to a // IRef object that presumably has been pre-pushed onto the server from // the client. // Evaluate the sql Query. var query = new SqlQuery(text, parameterStyle); if (parameters != null) { foreach (var p in parameters) { var c = p.SqlType.TypeCode; switch (c) { case SqlTypeCode.Blob: case SqlTypeCode.Clob: case SqlTypeCode.LongVarBinary: case SqlTypeCode.LongVarChar: case SqlTypeCode.VarBinary: throw new NotImplementedException("TODO: Download the Large-Objects and replace with a reference"); default: query.Parameters.Add(p); break; } } } var stopwatch = new Stopwatch(); stopwatch.Start(); var results = context.ExecuteQuery(query); var responses = new IQueryResponse[results.Length]; int j = 0; foreach (var result in results) { QueryResult queryResult; try { if (result.Type == StatementResultType.Exception) throw result.Error; queryResult = new QueryResult(query, result, context.AutoCommit()); resultId = AddResult(queryResult); } catch (Exception) { if (resultId != -1) DisposeResult(resultId); throw; } var taken = stopwatch.ElapsedMilliseconds; // Return the Query response responses[j] = new QueryResponse(resultId, queryResult, (int)taken, ""); j++; } stopwatch.Stop(); return responses; }