protected SoodaRelationTable(string tableName, string leftColumnName, string rightColumnName, Sooda.Schema.RelationInfo relationInfo) { this.relationInfo = relationInfo; this.tableName = tableName; this.leftColumnName = leftColumnName; this.rightColumnName = rightColumnName; }
public SoodaObjectOneToManyCollection(SoodaTransaction tran, Type childType, SoodaObject parentObject, string childRefField, Sooda.Schema.ClassInfo classInfo, SoodaWhereClause additionalWhereClause, bool cached) : base(tran, classInfo) { this.childType = childType; this.parentObject = parentObject; this.childRefField = childRefField; this.additionalWhereClause = additionalWhereClause; this.cached = cached; }
public SoodaObjectManyToManyCollection(SoodaTransaction transaction, int masterColumn, object masterValue, Type relationType, Sooda.Schema.RelationInfo relationInfo) : base(transaction, masterColumn == 0 ? relationInfo.GetRef1ClassInfo() : relationInfo.GetRef2ClassInfo()) { this.relationInfo = relationInfo; this.masterValue = masterValue; this.masterColumn = masterColumn; this.relationType = relationType; _factory = transaction.GetFactory(classInfo); }
protected TableBasedGeneratorBase(string keyName, Sooda.Schema.DataSourceInfo dataSourceInfo) { this.keyName = keyName; this.dataSourceInfo = dataSourceInfo; table_name = SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.name", "KeyGen"); key_name_column = SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.keycolumn", "key_name"); key_value_column = SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.valuecolumn", "key_value"); poolSize = Convert.ToInt32(SoodaConfig.GetString(dataSourceInfo.Name + ".keygentable.pool_size", "10")); }
public override string GetSQLDataType(Sooda.Schema.FieldInfo fi) { switch (fi.DataType) { case FieldDataType.Integer: case FieldDataType.BooleanAsInteger: case FieldDataType.TimeSpan: case FieldDataType.Long: return "integer"; case FieldDataType.AnsiString: if (fi.Size >= 4000) return "clob"; return "varchar2(" + fi.Size + ")"; case FieldDataType.String: if (fi.Size >= 2000) return "nclob"; return "nvarchar2(" + fi.Size + ")"; case FieldDataType.Decimal: if (fi.Size < 0) return "number"; if (fi.Precision < 0) return "number(" + fi.Size + ")"; return "number(" + fi.Size + "," + fi.Precision + ")"; case FieldDataType.Double: case FieldDataType.Float: if (fi.Size < 0) return "float"; if (fi.Precision < 0) return "float(" + fi.Size + ")"; return "float(" + fi.Size + "," + fi.Precision + ")"; case FieldDataType.DateTime: return "date"; case FieldDataType.Image: return "blob"; case FieldDataType.Boolean: return "number(1)"; case FieldDataType.Blob: return "blob"; default: throw new NotImplementedException(String.Format("Datatype {0} not supported for this database", fi.DataType)); } }
public override string GetSQLDataType(Sooda.Schema.FieldInfo fi) { switch (fi.DataType) { case FieldDataType.Integer: return "int"; case FieldDataType.String: return "varchar(" + fi.Size + ")"; case FieldDataType.DateTime: return "datetime"; default: throw new NotImplementedException(String.Format("Datatype {0} not supported for this database", fi.DataType.ToString())); } }
public virtual string GetAlterTableStatement(Sooda.Schema.TableInfo tableInfo) { return String.Format("alter table {0} add primary key", tableInfo.DBTableName); }
public void GenerateCreateTable(TextWriter xtw, Sooda.Schema.TableInfo tableInfo, string additionalSettings, string terminator) { xtw.WriteLine("create table {0} (", tableInfo.DBTableName); Dictionary<string, bool> processedFields = new Dictionary<string, bool>(); for (int i = 0; i < tableInfo.Fields.Count; ++i) { if (!processedFields.ContainsKey(tableInfo.Fields[i].DBColumnName)) { GenerateCreateTableField(xtw, tableInfo.Fields[i]); if (i == tableInfo.Fields.Count - 1) xtw.WriteLine(); else xtw.WriteLine(','); processedFields.Add(tableInfo.Fields[i].DBColumnName, true); } } xtw.Write(')'); TerminateDDL(xtw, additionalSettings, terminator); }
public TableBasedGenerator(string keyName, Sooda.Schema.DataSourceInfo dataSourceInfo) : base(keyName, dataSourceInfo) { }
object GetTypedFieldValue(Sooda.Schema.FieldInfo fi) { object value = _fieldValues.GetBoxedFieldValue(fi.ClassUnifiedOrdinal); if (value != null && fi.References != null) value = GetTransaction().GetFactory(fi.References).GetRef(GetTransaction(), value); return value; }
public SoodaDataSource OpenDataSource(Sooda.Schema.DataSourceInfo dataSourceInfo) { return OpenDataSource(dataSourceInfo, null); }
public override IDataReader ExecuteQuery(Sooda.QL.SoqlQueryExpression query, SchemaInfo schema, object[] parameters) { try { string queryText = SoqlToSql(query, schema, false); return ExecuteRawQuery(queryText, parameters); } catch (Exception ex) { logger.Error("Exception in ExecuteQuery: {0}", ex); throw; } }
public virtual bool IsNullValue(object val, Sooda.Schema.FieldInfo fi) { return val == null; }
public abstract string GetSQLOrderBy(Sooda.Schema.FieldInfo fi, bool start);
public void GenerateIndices(TextWriter xtw, Sooda.Schema.TableInfo tableInfo, string additionalSettings, string terminator) { foreach (Sooda.Schema.FieldInfo fi in tableInfo.Fields) { if (fi.References != null) GenerateIndex(xtw, fi, additionalSettings, terminator); } }
public void GeneratePrimaryKey(TextWriter xtw, Sooda.Schema.TableInfo tableInfo, string additionalSettings, string terminator) { bool first = true; foreach (Sooda.Schema.FieldInfo fi in tableInfo.Fields) { if (fi.IsPrimaryKey) { if (first) { xtw.Write(GetAlterTableStatement(tableInfo)); xtw.Write(" ("); } else { xtw.Write(", "); } xtw.Write(fi.DBColumnName); first = false; } } if (!first) { xtw.Write(')'); TerminateDDL(xtw, additionalSettings, terminator); } }
public override string GetSQLOrderBy(Sooda.Schema.FieldInfo fi, bool start) { return ""; }
public override string GetSQLNullable(Sooda.Schema.FieldInfo fi) { switch (fi.DataType) { case FieldDataType.AnsiString: case FieldDataType.String: if (fi.Size < 4000) // IsNull works fine for Oracle clob, but for nvarchar2 isnull('') = true - contrary to ansi SQL-92 return "null"; break; default: break; } return base.GetSQLNullable(fi); }
// for Oracle empty string is also null string public override bool IsNullValue(object val, Sooda.Schema.FieldInfo fi) { if (val == null) return true; if (fi.DataType == FieldDataType.AnsiString || fi.DataType == FieldDataType.String) return ((string) val).Length == 0; return false; }
public override string GetSQLOrderBy(Sooda.Schema.FieldInfo fi, bool start) { switch (fi.DataType) { case FieldDataType.AnsiString: if (fi.Size > 2000) return start ? "cast(substr(" : ", 0, 2000) as varchar2(2000))"; return ""; case FieldDataType.String: if (fi.Size > 2000) return start ? "cast(substr(" : ", 0, 2000) as nvarchar2(2000))"; return ""; default: return ""; } }
public void GenerateForeignKeys(TextWriter xtw, Sooda.Schema.TableInfo tableInfo, string terminator) { foreach (Sooda.Schema.FieldInfo fi in tableInfo.Fields) { if (fi.References != null) { xtw.Write("alter table {0} add constraint {1} foreign key ({2}) references {3}({4})", tableInfo.DBTableName, GetConstraintName(tableInfo.DBTableName, fi.DBColumnName), fi.DBColumnName, fi.ReferencedClass.UnifiedTables[0].DBTableName, fi.ReferencedClass.GetFirstPrimaryKeyField().DBColumnName ); xtw.Write(terminator ?? GetDDLCommandTerminator()); } } }
public override string GetSQLOrderBy(Sooda.Schema.FieldInfo fi, bool start) { switch (fi.DataType) { case FieldDataType.AnsiString: if (fi.Size > 4000) return start ? "convert(varchar(3999), " : ")"; else return ""; case FieldDataType.String: if (fi.Size > 4000) return start ? "convert(nvarchar(3999), " : ")"; else return ""; default: return ""; } }
public abstract string GetSQLDataType(Sooda.Schema.FieldInfo fi);
public override string GetAlterTableStatement(Sooda.Schema.TableInfo tableInfo) { string ident = GetTruncatedIdentifier(String.Format("PK_{0}", tableInfo.DBTableName)); return String.Format("alter table {0} add constraint {1} primary key", tableInfo.DBTableName, ident); }
public virtual string GetSQLNullable(Sooda.Schema.FieldInfo fi) { if (fi.IsDynamic) return "not null"; if (fi.IsNullable) return "null"; if (fi.ReferencedClass == null || fi.IsPrimaryKey || fi.ParentRelation != null || fi.ReadOnly || fi.ParentClass.ReadOnly) return "not null"; if (fi.PrecommitTypedValue == SchemaInfo.NullPrecommitValue) return "null"; return "not null"; }
public override string GetSQLDataType(Sooda.Schema.FieldInfo fi) { switch (fi.DataType) { case FieldDataType.Integer: return "int"; case FieldDataType.AnsiString: if (fi.Size > 4000) return "text"; else return "varchar(" + fi.Size + ")"; case FieldDataType.String: if (fi.Size > 4000) return "ntext"; else return "nvarchar(" + fi.Size + ")"; case FieldDataType.Decimal: if (fi.Size < 0) return "decimal"; else if (fi.Precision < 0) return "decimal(" + fi.Size + ")"; else return "decimal(" + fi.Size + "," + fi.Precision + ")"; case FieldDataType.Guid: return "uniqueidentifier"; case FieldDataType.Double: if (fi.Size < 0) return "float"; else if (fi.Precision < 0) return "float(" + fi.Size + ")"; else return "float(" + fi.Size + "," + fi.Precision + ")"; case FieldDataType.Float: if (fi.Size < 0) return "float"; else if (fi.Precision < 0) return "float(" + fi.Size + ")"; else return "float(" + fi.Size + "," + fi.Precision + ")"; case FieldDataType.DateTime: return "datetime"; case FieldDataType.Image: return "image"; case FieldDataType.Long: return "bigint"; case FieldDataType.BooleanAsInteger: return "int"; case FieldDataType.TimeSpan: return "int"; case FieldDataType.Boolean: return "bit"; case FieldDataType.Blob: return "varbinary(max)"; default: throw new NotImplementedException(String.Format("Datatype {0} not supported for this database", fi.DataType.ToString())); } }
public void GenerateCreateTableField(TextWriter xtw, Sooda.Schema.FieldInfo fieldInfo) { xtw.Write('\t'); xtw.Write(fieldInfo.DBColumnName); xtw.Write(' '); xtw.Write(GetSQLDataType(fieldInfo)); xtw.Write(' '); xtw.Write(GetSQLNullable(fieldInfo)); }
public static SoodaObject SelectSingleObjectWC(Sooda.SoodaWhereClause expr, ISoodaObjectList list) { if (list.Count == 0) return null; if (list.Count > 1) throw new SoodaObjectNotFoundException("Not a unique match: '" + expr + "'"); return list.GetItem(0); }
public SqlDataSourceDT(Sooda.Schema.DataSourceInfo dataSourceInfo) : this(dataSourceInfo.Name) { }
public static SoodaObject SelectSingleObjectBE(Sooda.QL.SoqlBooleanExpression expr, ISoodaObjectList list) { if (list.Count == 0) return null; if (list.Count > 1) throw new SoodaObjectNotFoundException("Not a unique match: '" + expr + "'"); return list.GetItem(0); }