Beispiel #1
0
        protected override SqlQuerySourceAttribute AddAttribute(string attrDefName)
        {
            string alias;
            SqlQuerySourceAttribute attribute;

            if (attrDefName.Length > 0 && attrDefName[0] == '&')
            {
                var ident = SystemIdentConverter.Convert(attrDefName);
                alias     = GetAttributeAlias(attrDefName);
                attribute = new SqlQueryDocSourceAttribute(ident, alias);
            }
            else
            {
                var attrDef = FindAttributeDef(attrDefName);
                if (attrDef == null)
                {
                    throw new ApplicationException(String.Format("Атрибут \"{0}\" не найден!", attrDefName));
                }
                alias     = GetAttributeAlias(attrDefName);
                attribute = new SqlQueryDocSourceAttribute(attrDef, alias);
            }
            AttributeAliases.Add(alias.ToUpper());

            Attributes.Add(attribute);

            return(attribute);
        }
Beispiel #2
0
        private void PrepareFields()
        {
            _fields.Clear();
            var i = 0;

            foreach (var attr in Query.Attributes)
            {
                _fields.Add(
                    new SqlQueryField
                {
                    Index           = i,
                    SelectAttribute = attr,
                    AttrDef         = attr.Def,
                    AttributeId     = attr.Def != null ? attr.Def.Id : Guid.Empty,
                    AttributeName   = attr.Def != null ? attr.Def.Name : SystemIdentConverter.Convert(attr.Ident),
                    IsIdent         = attr.IsSystemIdent,
                    Ident           = attr.IsSystemIdent ? attr.Ident : SystemIdent.Id,
                    IsExp           = attr.IsMultiExpression,
                    DocDef          = attr.Attributes[0].Source != null ? attr.Attributes[0].Source.GetDocDef() : null,
                    DocDefId        =
                        attr.Attributes[0].Source != null ? attr.Attributes[0].Source.GetDocDef().Id : Guid.Empty,
                    DataType = attr.IsSystemIdent
                            ? SystemIdentConverter.ToBaseType(attr.Ident)
                            : attr.Def != null
                                ? CissaDataTypeHelper.ConvertToBase(attr.Def.Type.Id)
                                : BaseDataType.Unknown
                });
                i++;
            }
        }
Beispiel #3
0
        protected override SqlQuerySourceAttribute AddAttribute(SystemIdent attrIdent)
        {
            var alias = GetAttributeAlias(SystemIdentConverter.Convert(attrIdent));
            SqlQuerySourceAttribute attribute = new SqlQueryDocSourceAttribute(attrIdent, alias);

            AttributeAliases.Add(alias.ToUpper());

            Attributes.Add(attribute);

            return(attribute);
        }
Beispiel #4
0
        public virtual bool SameAttrName(string name)
        {
            if (name.Length <= 0 || name[0] != '&')
            {
                return(Def != null &&
                       String.Equals(Def.Name, name, StringComparison.OrdinalIgnoreCase));
            }

            var ident = SystemIdentConverter.Convert(name);

            return(Def == null && Ident == ident);
        }
Beispiel #5
0
        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));
        }