예제 #1
0
 public IDocumentMapping MappingFor(Type documentType)
 {
     return(_mappings.GetOrAdd(documentType, type =>
     {
         return StoreOptions.AllDocumentMappings.SelectMany(x => x.SubClasses)
         .FirstOrDefault(x => x.DocumentType == type) as IDocumentMapping
         ?? StoreOptions.MappingFor(type);
     }));
 }
예제 #2
0
        public ForeignKeyDefinition AddForeignKey(MemberInfo[] members, Type referenceType)
        {
            var referenceMapping = _storeOptions.MappingFor(referenceType);

            var duplicateField = DuplicateField(members);

            var foreignKey = new ForeignKeyDefinition(duplicateField.ColumnName, this, referenceMapping);

            ForeignKeys.Add(foreignKey);

            return(foreignKey);
        }
예제 #3
0
        public void Add(IProjection projection)
        {
            if (projection == null)
            {
                throw new ArgumentNullException(nameof(projection));
            }
            if (projection.Produces == null)
            {
                throw new InvalidOperationException("projection.Produces is null. Projection should defined the produced projection type.");
            }

            _options.MappingFor(projection.Produces);
            _projections.Add(projection);
        }
예제 #4
0
        public IDocumentMapping MappingFor(Type documentType)
        {
            return(_mappings.GetOrAdd(documentType, type =>
            {
                if (type == typeof(EventStream))
                {
                    return StoreOptions.Events.As <IDocumentMapping>();
                }

                return
                StoreOptions.Events.AllEvents().FirstOrDefault(x => x.DocumentType == type)
                ?? StoreOptions.AllDocumentMappings.SelectMany(x => x.SubClasses)
                .FirstOrDefault(x => x.DocumentType == type) as IDocumentMapping
                ?? StoreOptions.MappingFor(type);
            }));
        }
예제 #5
0
 public void Add(IProjection projection)
 {
     _options.MappingFor(projection.Produces);
     _projections.Add(projection);
 }