示例#1
0
 internal BasicFieldInfo(DataEntityMapping tableMapping, bool customName, string name)
 {
     if (tableMapping == null)
     {
         throw new ArgumentNullException(nameof(tableMapping));
     }
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     TableMapping = tableMapping;
     if (customName)
     {
         DataField = new CustomFieldMapping(name, tableMapping);
     }
     else
     {
         DataField = TableMapping.FindDataEntityField(name) ?? new CustomFieldMapping(name, tableMapping);
     }
 }
示例#2
0
        protected virtual void InitialRelateMappingInc()
        {
            DataEntityMapping mapping = DataEntityMapping.GetEntityMapping(this.relateType);

            DataFieldInfo []    infos  = new DataFieldInfo [keyPairs.Length];
            DataFieldMapping [] fields = new DataFieldMapping [keyPairs.Length];
            for (int i = 0; i < this.keyPairs.Length; i++)
            {
                DataFieldMapping field = mapping.FindDataEntityField(keyPairs [i].RelateKey);
                if (field == null)
                {
                    throw new LightDataException(string.Format(SR.CanNotFindTheSpecifiedField, mapping.ObjectType, keyPairs[i].RelateKey));
                }
                fields [i] = field;
                infos [i]  = new DataFieldInfo(field);
            }
            this.relateInfos         = infos;
            this.relateFieldMappings = fields;
            this.relateEntityMapping = mapping;
        }
示例#3
0
 protected BaseRelationFieldMapping(string fieldName, DataEntityMapping mapping, Type relateType, RelationKey [] keyPairs, PropertyHandler handler)
 {
     if (fieldName == null)
     {
         throw new ArgumentNullException(nameof(fieldName));
     }
     if (mapping == null)
     {
         throw new ArgumentNullException(nameof(mapping));
     }
     if (relateType == null)
     {
         throw new ArgumentNullException(nameof(relateType));
     }
     if (keyPairs == null || keyPairs.Length == 0)
     {
         throw new ArgumentNullException(nameof(keyPairs));
     }
     if (handler == null)
     {
         throw new ArgumentNullException(nameof(handler));
     }
     this.fieldName           = fieldName;
     this.masterEntityMapping = mapping;
     this.relateType          = relateType;
     this.keyPairs            = keyPairs;
     this.handler             = handler;
     this.masterFieldMappings = new DataFieldMapping [keyPairs.Length];
     this.masterInfos         = new DataFieldInfo [keyPairs.Length];
     for (int i = 0; i < keyPairs.Length; i++)
     {
         DataFieldMapping field = mapping.FindDataEntityField(keyPairs [i].MasterKey);
         if (field == null)
         {
             throw new LightDataException(string.Format(SR.CanNotFindTheSpecifiedField, mapping.ObjectType, keyPairs[i].MasterKey));
         }
         this.masterFieldMappings [i] = field;
         this.masterInfos [i]         = new DataFieldInfo(field);
     }
 }