Пример #1
0
        /// <summary>
        /// Appends the current property name, e.g. <c>"Item.MyValue"</c>, to the attribute buffer.
        /// </summary>
        /// <param name="attribute">The current attribute</param>
        /// <param name="tblAlias">An alias to qualify the property name with.</param>
        /// <param name="propName">A name to suffix the property name with.</param>
        /// <returns>A new attribute containing the appended buffer.</returns>
        public static IProjectionAttribute Prop(this IProjectionAttribute attribute, string tblAlias = null, string propName = null)
        {
            if ((propName == null || attribute.Field != null) && attribute.Metadata.HasFlag(RelationMetadataFlags.Model))
            {
                throw ProjectionException.FromProjection(attribute, "Cannot reference model directly.");
            }

            if (attribute.Field != null)
            {
                IField field = attribute.Field();

                ColumnBinding binding = new ColumnBinding(field.Identity.Name, field);

                propName = attribute.Context.Domain.Dialect.Identifier(binding.ColumnName);

                return(attribute.Append(propName).Append(binding));
            }
            else
            {
                string fullName = attribute.Metadata.Identity.Name;

                if (propName != null)
                {
                    fullName = attribute.Identity.Schema.Notation.Combine(fullName, propName);
                }

                if (tblAlias != null)
                {
                    attribute = attribute.Append(attribute.Context.Domain.Dialect.Identifier(tblAlias));
                    attribute = attribute.Append(attribute.Context.Domain.Dialect.Qualifier);
                }

                return(attribute.Append(attribute.Context.Domain.Dialect.Identifier(fullName)));
            }
        }
Пример #2
0
        public static IField GetFieldValue(IProjectionAttribute attribute)
        {
            if (attribute.Field == null)
            {
                throw ProjectionException.ValueNotFound(attribute);
            }

            return(attribute.Field());
        }