Exemple #1
0
        /// <summary>
        /// Adds a new attribute to the model.
        /// </summary>
        /// <param name="desc">The descriptor.</param>
        /// <returns>EntityAttr.</returns>
        public virtual MetaEntityAttr AddEntityAttr(MetaEntityAttrDescriptor desc)
        {
            var attr = CreateEntityAttr(desc);

            attr.Entity.Attributes.Add(attr);
            AssignEntityAttrID(attr);
            return(attr);
        }
Exemple #2
0
        /// <summary>
        /// Creates the entity attribute. Used for creating entity attributes while building the model
        /// </summary>
        /// <param name="desc">The descriptor</param>
        /// <returns></returns>
        public MetaEntityAttr CreateEntityAttr(MetaEntityAttrDescriptor desc)
        {
            if (desc == null)
            {
                throw new ArgumentNullException(nameof(desc));
            }

            var attr = CreateEntityAttrCore(desc.Parent, desc.Kind);

            if (!string.IsNullOrEmpty(desc.Expression))
            {
                attr.Id = DataUtils.ComposeKey(desc.Parent?.Id, desc.Expression);
            }
            attr.Expr     = desc.Expression;
            attr.Caption  = desc.Caption;
            attr.DataType = desc.DataType;
            attr.Size     = desc.Size;

            return(attr);
        }