public SqlQueryJoin(SqlQuerySource source, SqlQuerySource target, SqlSourceJoinType joinType, Guid attrDefId) { Source = source; Target = target; JoinType = joinType; SqlQuerySource attrSource; JoinAttrDef = Source.FindAttributeDef(attrDefId); if (JoinAttrDef != null) { attrSource = Source; } else { JoinAttrDef = Target.FindAttributeDef(attrDefId); attrSource = Target; IsTargetAttribute = true; } // if (JoinAttrDef.Type.Id == (short)CissaDataType.Doc) if (JoinAttrDef != null) { JoinAttribute = attrSource.GetAttribute(JoinAttrDef.Id); } }
private ICollection <SqlQueryCondition> GetSourceConditions(SqlQuerySource source) { var sourceConditions = new List <SqlQueryCondition>(); FillSourceConditions(source, sourceConditions); return(sourceConditions); }
private static SqlQuerySource AddJoinDocConditions(SqlQuery query, SqlQuerySource master, DocAttribute attr) { var source = query.JoinSource(master, attr.Document.DocDef.Id, SqlSourceJoinType.Inner, attr.AttrDef.Id); AddDocConditions(query, source, attr.Document); return(source); }
private ICollection <SqlQueryCondition> GetExternalSourceConditions(SqlQuerySource source, ICollection <SqlQueryCondition> sourceConditions) { var externalConditions = new List <SqlQueryCondition>(); FillExternalSourceConditions(source, sourceConditions, externalConditions); return(externalConditions); }
public void FillSourceConditions(SqlQuerySource source, ICollection <SqlQueryCondition> sourceConditions) { if (!HasOrConditions()) { foreach (var condition in this) { if (condition.Condition == ConditionOperation.Include || condition.Condition == ConditionOperation.Exp) { if (condition.Conditions == null || condition.Conditions.Count == 0) { continue; } if (condition.Conditions.HasOrConditions()) { var sources = condition.Conditions.GetSources(); if (sources.Count == 1 && sources[0] == source) { sourceConditions.Add(condition); } /*foreach (var sub in conditions) * sourceConditions.Add(sub);*/ } else { condition.Conditions.FillSourceConditions(source, sourceConditions); } } else { var sources = new List <SqlQuerySource>(); FillConditionSources(sources, condition); if (sources.Count == 1 && sources[0] == source) { sourceConditions.Add(condition); } } } } else { var sources = GetSources(); if (sources.Count == 1 && sources[0] == source) { foreach (var condition in this) { sourceConditions.Add(condition); } } } }
public int TryGetAttributeIndex(SqlQuerySource source, Guid attrDefId) { var attr = Query.Attributes.FirstOrDefault(a => a.Source == source && a.Def != null && a.Def.Id == attrDefId); if (attr == null) { return(-1); } return(Query.Attributes.IndexOf(attr)); }
public SqlQueryCondition AddCondition(ExpressionOperation operation, SqlQuerySource source1, string attrDefName1, ConditionOperation condition, SqlQuerySource source2, string attrDefName2, SqlQueryCondition parentCondition = null) { var item = new SqlQueryCondition(operation, source1, attrDefName1, condition, source2, attrDefName2); if (parentCondition == null) { Conditions.Add(item); } else { parentCondition.Conditions.Add(item); } return(item); }
public SqlQueryCondition AddCondition(ExpressionOperation operation, SqlQuerySource source, string attrDefName, ConditionOperation condition, object value, SqlQueryCondition parentCondition = null) { var item = new SqlQueryCondition(source, operation, attrDefName, condition, value); if (parentCondition == null) { Conditions.Add(item); } else { parentCondition.Conditions.Add(item); } return(item); }
public void FillExternalSourceConditions(SqlQuerySource source, ICollection <SqlQueryCondition> sourceConditions, ICollection <SqlQueryCondition> externalConditions) { foreach (var condition in this) { if (condition.Condition == ConditionOperation.Include || condition.Condition == ConditionOperation.Exp) { if (sourceConditions.Contains(condition)) { continue; } if (condition.Conditions == null || condition.Conditions.Count == 0) { continue; } if (condition.Conditions.HasOrConditions()) { externalConditions.Add(condition); } else { condition.Conditions.FillExternalSourceConditions(source, sourceConditions, externalConditions); } } else { if (sourceConditions.Contains(condition)) { continue; } var sources = new List <SqlQuerySource>(); FillConditionSources(sources, condition); if (sources.Contains(source)) { externalConditions.Add(condition); } } } }
/*private static void AddFormControls(SqlQuery query, SqlQuerySource source, IEnumerable<BizControl> children) * { * if (children == null) return; * * foreach(var control in children) * { * if (control is BizDataControl && ((BizDataControl)control).AttributeDefId != null) * { * if (control is BizDocumentControl && control.Children != null && control.Children.Count > 0) * { * var docControl = (BizDocumentControl) control; * var attr = source.GetDocDef().Attributes.First(a => a.Id == (Guid) docControl.AttributeDefId); * * var slave = query.JoinSource(source, attr.DocDefType, SqlSourceJoinType.Inner, attr.Id); * * AddFormControls(query, slave, control.Children); * } * else * query.AddAttribute(source, (Guid) ((BizDataControl) control).AttributeDefId); * } * * } * }*/ public static void AddDocConditions(SqlQuery query, SqlQuerySource source, Doc filter) { if (filter == null) { return; } foreach (var attr in filter.Attributes) { if (attr is DocAttribute) { if (((DocAttribute)attr).Document != null && HasDocumentValue(((DocAttribute)attr).Document)) { AddJoinDocConditions(query, source, (DocAttribute)attr); } } else if (attr is DocListAttribute) { // if (((DocListAttribute)attr).AddedDocIds != null) } else if (attr.ObjectValue != null) { if (attr is TextAttribute) { var txt = ((TextAttribute)attr).Value; if (!String.IsNullOrEmpty(txt)) { query.AddCondition(ExpressionOperation.And, attr.AttrDef.Id, ConditionOperation.Like, txt); } } else { query.AddCondition(ExpressionOperation.And, attr.AttrDef.Id, ConditionOperation.Equal, attr.ObjectValue); } } } }
public int TryGetAttributeIndex(SqlQuerySource source, string attrDefName) { SqlQuerySelectAttribute attr; if (attrDefName.Length > 0 && attrDefName[0] == '&') { var ident = SystemIdentConverter.Convert(attrDefName); attr = Query.Attributes.FirstOrDefault(a => a.Source == source && a.IsSystemIdent && a.Attribute.Ident == ident); } else { attr = Query.Attributes.FirstOrDefault( a => a.Source == source && String.Equals(a.Def.Name, attrDefName, StringComparison.OrdinalIgnoreCase)); } if (attr == null) { return(-1); } return(Query.Attributes.IndexOf(attr)); }
public SqlQueryJoinBuilder(SqlQuery query, SqlQuerySource source) : this(null, query, source) { }
public SqlQueryOrderAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute, bool asc) : base(source, attribute) { Asc = asc; }
public SqlQueryConditionBuilder(SqlQueryConditionBuilder parent, SqlQuery query, SqlQuerySource source) { Parent = parent; Query = query; Source = source; }
public SqlQueryJoinBuilder(SqlQueryJoinBuilder parent, SqlQuery query, SqlQuerySource source) { Query = query; Source = source; Parent = parent; }
protected SqlQueryAttribute(SqlQuerySource source, Guid attrDefId, string expression) : this(source, attrDefId) { Expression = expression; }
protected SqlQueryAttribute(SqlQuerySource source, string attrDefName, string expression) : this(source, attrDefName) { Expression = expression; }
protected SqlQueryAttribute(SqlQuerySource source, SystemIdent attrIdent) { _attributes.Add(new SqlQuerySourceAttributeRef(source, source.GetAttribute(attrIdent))); }
protected SqlQueryAttribute(SqlQuerySource source, SystemIdent attrIdent, string exp) : this(source, attrIdent) { Expression = exp; }
public SqlQuerySourceAttributeRef(SqlQuerySource source, string attrDefName) { Source = source; Attribute = source.GetAttribute(attrDefName); }
public SqlQueryOrderAttribute(SqlQuerySource source, Guid attrDefId) : this(source, attrDefId, true) { }
public SqlQueryOrderAttribute(SqlQuerySource source, SystemIdent attrIdent, string exp, bool asc) : base(source, attrIdent, exp) { Asc = asc; }
public SqlQueryOrderAttribute(SqlQuerySource source, Guid attrDefId, bool asc) : base(source, attrDefId) { Asc = asc; }
public SqlQuerySourceAttributeRef(SqlQuerySource source, SystemIdent attrIdent) { Source = source; Attribute = source.GetAttribute(attrIdent); }
public SqlQueryOrderAttribute(SqlQuerySource source, string attrDefName, bool asc) : base(source, attrDefName) { Asc = asc; }
protected SqlQueryAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute) { _attributes.Add(new SqlQuerySourceAttributeRef(source, attribute)); }
public SqlQueryOrderAttribute(SqlQuerySource source, Guid attrDefId, string expression, bool asc) : base(source, attrDefId, expression) { Asc = asc; }
protected SqlQueryAttribute(SqlQuerySource source, Guid attrDefId) { _attributes.Add(new SqlQuerySourceAttributeRef(source, source.GetAttribute(attrDefId))); }
public SqlQueryOrderAttribute(SqlQuerySource source, string attrDefName) : this(source, attrDefName, true) { }
protected SqlQueryAttribute(SqlQuerySource source, string attrDefName) { _attributes.Add(new SqlQuerySourceAttributeRef(source, source.GetAttribute(attrDefName))); }