Beispiel #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);
     }));
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
            }));
        }
 public void Add(IProjection projection)
 {
     _options.MappingFor(projection.Produces);
     _projections.Add(projection);
 }