One: LINQ is not a unique query for EF ...
Two: Entity Sql
1. ESQL = Entity SQL ... "Class SQL language" is about the same as SQL, but not SQL ...
using (schooldbentities db = new Schooldbentities ())
{
Querying with Object Services and Entity SQL
String sqlString = "Select Value s from schooldbentities.students as S"; SELECT * FROM Student
var objctx = (db as Iobjectcontextadapter). ObjectContext;
Objectquery<student> Student = objctx. Createquery<student> (sqlString);
var query = student. ToList ();
}
Learn about a grammar ...
Official website: https://msdn.microsoft.com/zh-cn/library/bb399560.aspx
2. Entityconnection,entitycommand ....
Use the soundtrack for a little bit of command
using (var con = new EntityConnection ("Name=schooldbentities"))
The "Name=schooldbentities" here is the database connection string that gets the Schooldbentities node in the AppConfig
using (var con = new EntityConnection ("Name=schooldbentities"))
{
Con. Open ();
EntityCommand cmd = con. CreateCommand ();
Cmd.commandtext = "Select VALUE St from schooldbentities.students as St where St." Studentname= ' Nihao ' ";
Dictionary<int, string> dict = new Dictionary<int, string> ();
using (entitydatareader rdr = cmd. ExecuteReader (CommandBehavior.SequentialAccess | CommandBehavior.CloseConnection))
{
while (RDR. Read ())
{
int a = RDR. GetInt32 (0);
var B = rdr. GetString (1);
Dict. Add (A, b);
}
}
}
Rsql + raw sql ... "pour directly into SQL into DB"
People choose according to their hobbies ...
3. Rsql:
"1" repository in the Rsql query ....
Curd operation ...
1. R:var query = db. Students.sqlquery ("SELECT * from Student"). ToList ();
"2" at database level
1. R:var query = db. Database.sqlquery<student> ("SELECT * from Student"). ToList ();
2. c,u,d var query = db. Database.executesqlcommand ("Update Student set studentname= ' Jack2 ' where studentname= ' Jack '");
LINQ is too complex to write well ... Even with the linqer,linqpad ... LINQ <=> SQL
Learn about Entity Framework Other query methods Sql,raw SQL Analysis