Example #1
0
        public static SchemaBuilder Entity(this SchemaBuilder builder, EntityContext entity)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var entityBuilder = EntityBuilder.FromEntity(entity);

            return(Entity(builder, entityBuilder));
        }
Example #2
0
        private static SchemaBuilder Entity(this SchemaBuilder builder, EntityBuilder entityBuilder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (entityBuilder == null)
            {
                throw new ArgumentNullException(nameof(entityBuilder));
            }

            var key = entityBuilder.EntityAlias ?? entityBuilder.EntityName;

            if (builder.Entities.ContainsKey(key))
            {
                throw new DuplicateEntitiesException(key);
            }

            builder.Entities.Add(key, entityBuilder);

            return(builder);
        }
Example #3
0
        private static EntityContext BuildEntity(SchemaBuilder schemaBuilder, EntityBuilder entityBuilder)
        {
            if (entityBuilder.EntitySource == null)
            {
                if (schemaBuilder.DefaultSource == null)
                {
                    throw new DataSourceNotDefinedException(entityBuilder.EntityName);
                }

                entityBuilder.Source(schemaBuilder.DefaultSource);
            }

            if (entityBuilder.PropertyComparer == null)
            {
                var globalComparer = schemaBuilder.ComparerProvider.PropertyNameComparer;

                if (globalComparer != null)
                {
                    entityBuilder.PropertyNameComparer(globalComparer);
                }
            }

            return(entityBuilder.Build());
        }