0

I have a database with 2 tables :

  1. Personal : ID (PK), Name, Code (FK), Birthdate
  2. Social : Code (PK), Address

When I add a ADO.NET Entity Data Model name Model to my project. The Model.Context.tt has only Personals and Socials Dbset<>, so i can only choose 2 tables by using query :

string sql = "SELECT VALUE p FROM SqlEntities.Personals AS p"

SqlEntities is my entity name, so the thing i want is how to make a column in table become the Dbset<>, maybe I don't understand much but how i can use the anonymous type like :

stringsql = "SELECT p.ID, p.Name FROM SqlEntities.Personals AS p"

Model.Context.tt

EGHM
  • 2,144
  • 23
  • 37

1 Answers1

0

With projection, it is possible to make the query return only some columns from one table, or to return selected columns from multiple tables joined together. Projection is done with the Select() method and supports anonymous types:

db.Personals.Select(x => new { ID = x.ID, Name = x.Name });
Martin Staufcik
  • 8,295
  • 4
  • 44
  • 63