public void Set(SelectSql sql) { if (null != sql) { if (!this.Value.IsNull() && (this.TableName.Length != 0 && this.ColumnName.Length != 0)) { sql.Where(this.TableName, this.ColumnName, this.Operator, this.Value); } } }
public void Set(SelectSql sql) { if (null != sql) { if (this.Text.Length != 0 && (this.TableName.Length != 0 && this.ColumnName.Length != 0)) { sql.Where(this.TableName, this.ColumnName, this.Operator, base.Text); } } }
public void Set(SelectSql sql) { if (null != sql) { DateTime? value = base.SelectedDate; if (value.HasValue && (this.TableName.Length != 0 && this.ColumnName.Length != 0)) { sql.Where(this.TableName, this.ColumnName, this.Operator, value.Value); } } }
public static SelectSql ToAttributeBasedSelectSql(this Type entityType) { if (null != entityType) { object[] attributes = entityType.GetCustomAttributes(true); List<SqlTableAttribute> tables = new List<SqlTableAttribute>(); List<SqlJoinAttribute> joins = new List<SqlJoinAttribute>(); if (!attributes.IsEmptyList()) { var tempTables = attributes.OfType<SqlTableAttribute>(); if (!tempTables.IsEmptyList()) { tables.AddRange(tempTables); } var tempJoins = attributes.OfType<SqlJoinAttribute>(); if (!tempJoins.IsEmptyList()) { joins.AddRange(tempJoins); } } if (tables.Count == 0) tables.Add(new SqlTableAttribute(entityType.Name)); List<SqlColumnAttribute> columns = new List<SqlColumnAttribute>(); foreach (PropertyInfo pi in entityType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { SqlColumnAttribute ca = pi.GetCustomAttribute<SqlColumnAttribute>(); if (null != ca) { if (String.IsNullOrEmpty(ca.Column)) ca.Column = pi.Name; if (String.IsNullOrEmpty(ca.Alias)) ca.Alias = pi.Name; } else { ca = new SqlColumnAttribute(null, pi.Name, null); } columns.Add(ca); } if (columns.Count == 0) throw new InvalidOperationException(entityType.FullName + " has no valid property"); SelectSql sql = new SelectSql(); foreach (SqlTableAttribute item in tables) { sql.Table(item.Table, item.Alias); if (item.IsLeftTable) { if (!String.IsNullOrEmpty(item.Alias)) sql.SetLeftTable(item.Alias); else sql.SetLeftTable(item.Table); } } foreach (SqlJoinAttribute item in joins) { sql.Join(item.LeftTable, item.LeftColumn, item.Join, item.RightTable, item.RightColumn); } foreach (SqlColumnAttribute item in columns) { sql.Column(item.Table, item.Column, item.Alias); } return sql; } return null; }