private void FinalizeMapReading() { if (!PrimaryKeyMaps.Any()) { throw new Exception("No primary key maps found on " + typeof(T).Name + ". Use the AutonumberAttribute or KeyAttribute to mark a property as a primary key."); } if (StandardMaps.Any()) { AllMaps.AddRange(StandardMaps); } AllMaps.AddRange(PrimaryKeyMaps); if (!AllMaps.Any()) { throw new Exception("No mappable properties found on " + typeof(T).Name); } AllMapsDictionary = new Dictionary <string, string>(); foreach (IMap map in AllMaps) { AllMapsDictionary.Add(map.PropertyName, map.ColumnName); } }
private void ProcessMapList(IEnumerable <IMap> maps) { foreach (IMap map in maps) { if (map.ColumnName == null) { continue; } if (map is AutonumberMap) { if (AutonumberMap != null) { throw new Exception("Multiple autonumber maps cannot be assigned"); } if (PrimaryKeyMaps.Any()) { throw new Exception("The class already has ID maps assigned. Autonumbers cannot be used eith IDMaps"); } AutonumberMap = map as AutonumberMap; PrimaryKeyMaps.Add(map as Map); } else if (map is IDMap) { if (AutonumberMap != null) { throw new Exception("Autonumber map already assigned entities cannot have autonumber and ID maps"); } PrimaryKeyMaps.Add(map as Map); } else { StandardMaps.Add(map as Map); } } }