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

  var qry= dataContext.Parent
                   .GroupJoin(
                      dataContext.ChildItems,
                      dl => dl.LinkId,
                      itm => (Int32?)(itm.ChildItemId),
                      (x, y) =>
                         new
                         {
                             Parent = x,
                             ChildItems = y
                         }
                   )
                   .Where(x => (((x.Parent.ParentId == 1)) 
                       && (x.Parent.LinkTypeId == 1)
                   )
                   .SelectMany(
                      x => x.ChildItems.DefaultIfEmpty(),
                      (x,y) => new { Parent=x.Parent, ChildItems=y});

            var tmpResult = result.ToList();
 

相关文章:

  • 2021-12-24
  • 2021-12-24
  • 2021-12-24
  • 2021-11-07
  • 2021-08-14
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-01-23
  • 2021-12-24
相关资源
相似解决方案