1,创建数据库: MyLINQ表 ->Player 和 MyLevel

2,创建MYLINQ.dbml,建立关系映射->同时 系统 会自动建立 MYDBDataContext 类

private void dbQuery() {    var db = new MYDBDataContext();    var result = from c in db.Player                 where c.id == 1                 select c;    foreach (var c in result) {        Console.WriteLine(c.name);    }}

多表联合查询:

private void joinQuery() {    var db = new MYDBDataContext();    var result = from c in db.Player                 from o in db.myLevel                 where c.mylevel == o.id                 select new { c.name , o.id };    foreach (var c in result) {        Console.WriteLine(c.name, c.id);    }}