public IDataModel Read(int id) { using(var db = new GisDataBase()) { return Mapper.Map<Company,CompanyModel>(db.Companies.FirstOrDefault(x => x.ID == id)); } }
public IEnumerable<IDataModel> Read() { var companies = new List<CompanyModel>(); using (var db = new GisDataBase()) { companies.AddRange(db.Companies.Select(company => Mapper.Map<Company, CompanyModel>(company))); } return companies; }