Exemplo n.º 1
0
        private static bool HasQuerySourceAttributeConditions(SqlQuerySourceAttribute attribute,
                                                              IEnumerable <SqlQueryCondition> conditions)
        {
            if (conditions == null)
            {
                return(false);
            }

            foreach (var condition in conditions)
            {
                var b = false;

                if ((condition.Condition == ConditionOperation.Exp ||
                     condition.Condition == ConditionOperation.Include) &&
                    condition.Conditions != null)
                {
                    b = condition.Conditions.All(
                        c => c.Left.Attributes != null && c.Left.Attributes.All(a => a.Attribute == attribute) &&
                        (!c.Right.IsAttribute || c.Right.Attributes.All(a => a.Attribute == attribute)));
                }
                else if (condition.Attributes != null)
                {
                    b = condition.Left.Attributes.All(attr => attr.Attribute == attribute) &&
                        (!condition.Right.IsAttribute ||
                         condition.Right.Attributes.All(a => a.Attribute == attribute));
                }
                if (b)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private static object GetSubQueryAttrAlias(SqlQuerySourceAttribute attr)
        {
            var subQueryAttr = attr as SqlQuerySubSourceAttribute;

            if (subQueryAttr != null && subQueryAttr.Attribute != null)
            {
                return(String.IsNullOrEmpty(subQueryAttr.Attribute.Alias)
                    ? subQueryAttr.Attribute.AliasName
                    : subQueryAttr.Attribute.Alias);
            }
            return(attr.AliasName);
        }
Exemplo n.º 3
0
 public SqlQueryOrderAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute, bool asc) : base(source, attribute)
 {
     Asc = asc;
 }
Exemplo n.º 4
0
 protected SqlQueryAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute)
 {
     _attributes.Add(new SqlQuerySourceAttributeRef(source, attribute));
 }
Exemplo n.º 5
0
        private static IEnumerable <SqlQueryCondition> GetQuerySourceAttributeConditions(SqlQuerySourceAttribute attribute,
                                                                                         IEnumerable <SqlQueryCondition> conditions)
        {
            if (conditions == null)
            {
                yield break;
            }

            foreach (var condition in conditions)
            {
                var b = false;

                if ((condition.Condition == ConditionOperation.Exp ||
                     condition.Condition == ConditionOperation.Include) &&
                    condition.Conditions != null)
                {
                    b = condition.Conditions.All(
                        c => c.Condition != ConditionOperation.Exp && c.Condition != ConditionOperation.Include &&
                        c.Left.Attributes != null && c.Left.Attributes.All(a => a.Attribute == attribute) &&
                        (!c.Right.IsAttribute || c.Right.Attributes.All(a => a.Attribute == attribute))) &&
                        !condition.Conditions.Any(
                        c => c.Condition == ConditionOperation.IsNull || c.Condition == ConditionOperation.IsNotNull);
                }
                else if (condition.Attributes != null)
                {
                    b = condition.Left.Attributes.All(attr => attr.Attribute == attribute) &&
                        (!condition.Right.IsAttribute ||
                         condition.Right.Attributes.All(a => a.Attribute == attribute)) &&
                        !(condition.Condition == ConditionOperation.IsNull ||
                          condition.Condition == ConditionOperation.IsNotNull);
                }

/*
 *                  if (condition.SubQuery != null)
 *                  {
 *                      //condition.Left.SubQuery.Attribute.Attributes
 *                      continue;
 *                  }
 */
                if (b)
                {
                    yield return(condition);
                }
            }
        }
Exemplo n.º 6
0
 public SqlQuerySourceAttributeRef(SqlQuerySource source, SystemIdent attrIdent)
 {
     Source    = source;
     Attribute = source.GetAttribute(attrIdent);
 }
Exemplo n.º 7
0
 public SqlQuerySourceAttributeRef(SqlQuerySource source, string attrDefName)
 {
     Source    = source;
     Attribute = source.GetAttribute(attrDefName);
 }
Exemplo n.º 8
0
 public SqlQuerySourceAttributeRef(SqlQuerySource source, Guid attrDefId)
 {
     Source    = source;
     Attribute = source.GetAttribute(attrDefId);
 }
Exemplo n.º 9
0
 public SqlQuerySourceAttributeRef(SqlQuerySource source, SqlQuerySourceAttribute attribute)
 {
     Source    = source;
     Attribute = attribute;
 }
Exemplo n.º 10
0
 public SqlQueryGroupAttribute(SqlQuerySource source, SqlQuerySourceAttribute attribute)
     : base(source, attribute)
 {
 }