score:3

Yes, you can do:

Expression<Func<Person, PersonEntity>> ConvertToPersonEntity() {
  return x => new PersonEntity { Id = x.Id, Name = x.Name };
}

...and then:

PersonEntity GetById(int id) {
  var exp = ConvertToPersonEntity();
  return db.Person.FirstOrDefault(exp);
}

Related Articles