public ReferencingGenerator(TableGenerator table, PropertyInfo property, ReferencingAttribute referencingAttribuite)
        {
            if (!property.PropertyType.IsGenericType)
            {
                throw new InvalidOperationException($"{nameof(ReferencingAttribute)} Property type expect generic enumerable!");
            }

            var referenceTable = DBTable.GetTableAttributeInherit(property.PropertyType.GetGenericArguments()[0]);

            if (referenceTable == null)
            {
                throw new InvalidOperationException($"{nameof(ReferencingAttribute)} Property type expect {nameof(TableAttribute)}!");
            }

            var referenceColumn = referenceTable.GetColumnByProperty(referencingAttribuite.ReferenceProperty);

            if (referenceColumn == null)
            {
                throw new InvalidOperationException($"{nameof(ReferencingAttribute.ReferenceProperty)} expect {nameof(ColumnAttribute)}!");
            }
            Attribute       = referencingAttribuite;
            Table           = table;
            PropertyInfo    = property;
            ReferenceTable  = referenceTable;
            ReferenceColumn = referenceColumn;
            PropertyInvoker = EmitInvoker.Initialize(property, true);
        }
Beispiel #2
0
 public virtual void Initialize(Type type)
 {
     Type           = type;
     TableAttribute = DBTable.GetTableAttributeInherit(type.BaseType);
     if (TableAttribute == null)
     {
         throw new Exception($"Class with {nameof(ItemTypeAttribute)} must have are {nameof(Type.BaseType)} with {nameof(Data.TableAttribute)}!");
     }
     TableAttribute.InitializeItemType(this);
 }