Entity descriptor context.
상속: ITypeDescriptorContext
        /// <summary>
        /// Initialize entity context builder.
        /// </summary>
        /// <param name="context">Entity framework database context.</param>
        public EntityContextBuilder(DbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            DbContext = context;
            List <Type> types = new List <Type>();

            foreach (var property in context.GetType().GetProperties())
            {
                if (!property.PropertyType.IsGenericType)
                {
                    continue;
                }
                if (property.PropertyType.GetGenericTypeDefinition() != typeof(DbSet <>))
                {
                    continue;
                }
                types.Add(property.PropertyType.GetGenericArguments()[0]);
            }
            EntityTypes       = types.ToArray();
            cache             = new Dictionary <Type, object>();
            DescriptorContext = new EntityDescriptorContext(this);
        }
예제 #2
0
 /// <summary>
 /// Initialize with main builder.
 /// </summary>
 /// <param name="mainBuilder"></param>
 public MixedEntityContextBuilder(IEntityContextBuilder mainBuilder)
 {
     _Map              = new Dictionary <Type, IEntityContextBuilder>();
     _Context          = new Dictionary <Type, object>();
     _Types            = new List <Type>();
     MainBuilder       = mainBuilder;
     DescriptorContext = new EntityDescriptorContext(this);
     if (mainBuilder != null)
     {
         _Types.AddRange(mainBuilder.EntityTypes);
     }
 }
 /// <summary>
 /// Initialize.
 /// </summary>
 /// <param name="context">Entity descriptor context.</param>
 /// <param name="property">Property metadata.</param>
 public EntityValueConverterContext(EntityDescriptorContext context, PropertyMetadata property)
 {
     _Context = context;
     Property = property;
 }