using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using MapTo; namespace BlueWest.Data { [MapFrom(typeof(Currency))] public partial class CurrencyCreate { public int Num { get; set; } // Primary key [MaxLength(3)] public string Code { get; set; } public List CountriesToCreate { get; set; } public CurrencyCreate() { } public Currency ToCurrency() { List countries = new List(); foreach (var countryCreate in CountriesToCreate) { var newCountry = new Country(countryCreate, null, null); countries.Add(newCountry); } return new Currency(this, countries); } } }