//public bool Contains(Data.LogicalOperator LogicalOperator) //{ // return Items.Contains(LogicalOperator); //} public int IndexOf(ConditionCollection SearchConditions) { return(Items.IndexOf(SearchConditions)); }
public ConditionCollection Or(ConditionCollection SearchConditions) { this.Add(Tenor.Data.LogicalOperator.Or); return(this.Add(SearchConditions)); }
public bool Contains(ConditionCollection SearchConditions) { return(Items.Contains(SearchConditions)); }
/// <summary> /// Gets the value of a lazy tagged property. /// This call can do a database access. /// </summary> internal virtual object GetPropertyValue(string propertyName, bool forceGetBinary) { //only loads if not loaded yet. //TODO: provide a way to reload from database. lock (propertyData) { if (forceGetBinary || !propertyData.ContainsKey(propertyName)) { //Getting class metadata. TableInfo table = TableInfo.CreateTableInfo(this.GetType()); System.Reflection.PropertyInfo fieldP = this.GetType().GetProperty(propertyName); if (fieldP == null) { throw new Tenor.Data.MissingFieldException(this.GetType(), propertyName); } ForeignKeyInfo fkInfo = null; fkInfo = ForeignKeyInfo.Create(fieldP); if (fkInfo != null) { // this is an FK, so, route to fk loading return(LoadForeign(fieldP, null)); } else { //Continue to the lazy property (lazy fields like byte[]) loading FieldInfo field = FieldInfo.Create(fieldP); if (field == null) { throw new Tenor.Data.MissingFieldException(this.GetType(), fieldP.Name); } if (!forceGetBinary && (field.FieldType == typeof(BinaryStream) || field.FieldType == typeof(BinaryStream).BaseType)) { propertyData[propertyName] = new BinaryStream(this, propertyName); } else { GeneralDialect dialect = DialectFactory.CreateDialect(table.GetConnection()); ConditionCollection conditions = new ConditionCollection(); foreach (FieldInfo f in GetFields(this.GetType(), true)) { conditions.Add(f.RelatedProperty.Name, f.PropertyValue(this)); } if (conditions.Count == 0) { throw (new Tenor.Data.MissingPrimaryKeyException(this.GetType())); } TenorParameter[] parameters = null; string fieldsPart = dialect.CreateSelectSql(table.RelatedTable, null, new FieldInfo[] { field }, null, null); string wherePart = dialect.CreateWhereSql(conditions, table.RelatedTable, null, out parameters); string sql = dialect.CreateFullSql(table.RelatedTable, false, false, 0, fieldsPart, null, null, wherePart); Tenor.Diagnostics.Debug.DebugSQL("GetPropertyValue()", sql, parameters, table.GetConnection()); #if DEBUG LastSearches.Push(sql); #endif Tenor.Data.DataTable rs = new Tenor.Data.DataTable(sql, parameters, table.GetConnection()); rs.Bind(); if (rs.Rows.Count == 0) { throw (new RecordNotFoundException()); } else if (rs.Rows.Count > 1) { throw new ManyRecordsFoundException(); } else { var obj = rs.Rows[0][field.DataFieldName]; if (obj == DBNull.Value) { obj = null; } if (forceGetBinary) { if (obj == null) { return new byte[] { } } ; else { return(obj); } } else { propertyData[propertyName] = obj; } } } } } return(propertyData[propertyName]); } }