Post table: Posts
Id,
The title,
Addtime,
Memberid,
Modifytime
Post comments table: PostsComment
Id,
Postid,
Parentid,
The content
Query encounter a problem, when the current is used to render a page posts list page, want to accomplish is post sorting is according to the latest reply time for each post sorting, such linq should how to write?
Posts have 10 comments such as a, b posts have 20 comments, but b post comment number under the latest comments in time is a time recently, a post are long, long ago, comment according to such rules, the b post row in front of a post
CodePudding user response:
Have what problem? Would you want to achieve is post sorting is according to the latest reply time for each post sorting, b on time is the latest, front row of a, b to ahCodePudding user response:
Var data=https://bbs.csdn.net/topics/(from a in _posts LoadEntities (a=> true)The join r in _cooments. LoadEntities (r=& gt; True)
On Anderson d equals r.p ostid
Orderby state Richard armitage ddtime item first-just
Select a). ToList ();
Found out post so many are repeated, solving
CodePudding user response:
Dintinct good ah,CodePudding user response:
See postid connection condition, it should not be only one primary key, so more than likely data1, whether to have garbage data (artificial test entry)
Is to post comments table id is different, but the same content or content postid,
What is 2, the review table parentid
The only data plus parentid, whether can appear
CodePudding user response:
That you have to inside the card table and field ah: ListCodePudding user response:
No time field PostsComment table