public class Person {
public string Name { get; set; }
public int? Age { get; set; }
}
public class PersonDbContext :DbContext {
public PersonDbContext():
base("ConnectionString") {
}
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
Database.SetInitializer<PersonDbContext>(null);
}
}
public class Services {
private PersonDbContext pdbc = new PersonDbContext();
public List<Person> gePersontList() {
string sql = @"";
var result = pdbc.Database.SqlQuery<Person>(string.Format(sql,"")).ToList();
return result.Any() ? result : null;
}
}