Ejemplo n.º 1
0
        /// <summary>
        /// 通过托管属性及其对应的实体类型,并通过可用的缓存列表,查找对应的 DbTable。
        /// </summary>
        /// <param name="property"></param>
        /// <param name="propertyOwner"></param>
        /// <param name="tablesCache"></param>
        /// <returns></returns>
        internal static DbTable GetPropertyTable(IManagedProperty property, Type propertyOwner, Dictionary <Type, DbTable> tablesCache)
        {
            DbTable result = null;

            if (propertyOwner == null)
            {
                propertyOwner = property.OwnerType;
            }

            if (!tablesCache.TryGetValue(propertyOwner, out result))
            {
                if (!propertyOwner.IsAbstract)
                {
                    result = DbTableFinder.TableFor(propertyOwner);
                }

                if (result == null)
                {
                    ORMHelper.ThrowBasePropertyNotMappedException(property.Name, propertyOwner);
                }

                tablesCache.Add(propertyOwner, result);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public RefTableProperty(IRefIdProperty refProperty, Type propertyOwner)
        {
            this.PropertyOwner = propertyOwner;
            this.RefProperty   = refProperty;
            var mainTable = DbTableFinder.TableFor(propertyOwner);
            var refTable  = DbTableFinder.TableFor(refProperty.RefEntityType);

            this.OwnerTable = mainTable;
            this.RefTable   = refTable;
            this.FKName     = mainTable.Translate(refProperty);
        }