Linq.join_lambda知识点

Posted csskill

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linq.join_lambda知识点相关的知识,希望对你有一定的参考价值。

1、一直  不太明白 join的 lambda的写法,先记录一些我查到的东西:

 1.1、有关 Linq 与 Lambda 的Join连接查询_已解决_博问_博客园.htmlhttps://q.cnblogs.com/q/106310/

  ZC:里面有人说 “lambda 太长 比linq 恶心多了  短的时候用lambda  长的时候用linq”

 1.2、c# - Join_Where with LINQ and Lambda - Stack Overflow.html(https://stackoverflow.com/questions/2767709/join-where-with-linq-and-lambda

  ZC:里面的 被接受的回复:(ZC:可以对比一下 回复者的2中写法)

   I find that if you\'re familiar with SQL syntax, using the LINQ query syntax is much clearer, more natural, and makes it easier to spot errors:

   var id = 1;
   var query =
      from post in database.Posts
      join meta in database.Post_Metas on post.ID equals meta.Post_ID
      where post.ID == id
      select new { Post = post, Meta = meta };

   If you\'re really stuck on using lambdas though, your syntax is quite a bit off. Here\'s the same query, using the LINQ extension methods:

   var id = 1;
   var query = database.Posts    // your starting point - table in the "from" statement
      .Join(database.Post_Metas, // the source table of the inner join
         post => post.ID,        // Select the primary key (the first part of the "on" clause in an sql "join" statement)
         meta => meta.Post_ID,   // Select the foreign key (the second part of the "on" clause)
         (post, meta) => new { Post = post, Meta = meta }) // selection
      .Where(postAndMeta => postAndMeta.Post.ID == id);    // where statement

 

2、

3、

4、

5、

 

以上是关于Linq.join_lambda知识点的主要内容,如果未能解决你的问题,请参考以下文章

线程学习知识点总结

片段 getActivity 不起作用

Flutterflutter doctor 报错Android license status unknown. Run `flutter doctor --android-licenses‘(代码片段

R 知识片段

R 知识片段

python小知识片段