Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DynQueryDescriber"/> class.
        /// </summary>
        /// <param name="qa">The query attribute instance.</param>
        /// <param name="qa">The property's property info.</param>
        /// <param name="pi">The entity type that the property returns.</param>
        /// <param name="entityType">The entity type.</param>
        public DynQueryDescriber(QueryDynAttribute qa, DynPropertyConfiguration pi, string propertyEntityType, string entityType)
        {
            this.qa = qa;

            //parse info from pi
            propertyName = pi.Name;

            relatedEntityPropertyName = GetRelatedEntityPropertyName(qa);

            entityPk = GetPkPropertyName(entityType);

            relatedEntityType             = propertyEntityType;
            relatedEntityPk               = GetPkPropertyName(propertyEntityType);
            relatedEntityPkEntityProperty = GetPkEntityProperty(propertyEntityType);
            relatedEntityPkType           = GetPkPropertyType(propertyEntityType);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the pk property info of the specified entity type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>The property info.</returns>
        internal static DynPropertyConfiguration GetPkEntityProperty(string typeName)
        {
            DynPropertyConfiguration retPi = null;

            DynEntityType entityType = DynEntityTypeManager.GetEntityTypeMandatory(typeName);

            foreach (DynPropertyConfiguration item in entityType.GetProperties())
            {
                if (item.GetCustomAttributes(typeof(PrimaryKeyDynAttribute), item.IsInherited) != null)
                {
                    retPi = item;
                    break;
                }
            }

            if (retPi == null)
            {
                //check base entities
                foreach (DynEntityType baseType in entityType.GetAllBaseEntityTypes())
                {
                    foreach (DynPropertyConfiguration item in baseType.GetProperties())
                    {
                        if (item.GetCustomAttributes(typeof(PrimaryKeyDynAttribute), item.IsInherited) != null)
                        {
                            retPi = item;
                            break;
                        }
                    }
                    if (retPi != null)
                    {
                        break;
                    }
                }
            }

            return(retPi);
        }