Inheritance: IField
Esempio n. 1
0
        public DocumentMapping(Type documentType, StoreOptions storeOptions) : base("d.data", documentType, storeOptions)
        {
            if (documentType == null)
            {
                throw new ArgumentNullException(nameof(documentType));
            }
            if (storeOptions == null)
            {
                throw new ArgumentNullException(nameof(storeOptions));
            }

            _schemaObjects = new DocumentSchemaObjects(this);

            _storeOptions = storeOptions;

            DocumentType = documentType;
            Alias        = defaultDocumentAliasName(documentType);

            IdMember = FindIdMember(documentType);

            if (IdMember != null)
            {
                var idField = new IdField(IdMember);
                setField(IdMember.Name, idField);

                IdStrategy = defineIdStrategy(documentType, storeOptions);
            }

            applyAnyMartenAttributes(documentType);
        }
Esempio n. 2
0
        internal void Validate()
        {
            if (IdMember == null)
            {
                throw new InvalidDocumentException(
                          $"Could not determine an 'id/Id' field or property for requested document type {DocumentType.FullName}");
            }

            var idField = new IdField(IdMember);

            setField(IdMember.Name, idField);
        }