Home > Net >  The.net core one-to-many time sorting data table structure
The.net core one-to-many time sorting data table structure

Time:11-21

There is a post table and reply table,
Under the post list to post the latest reply to sorting,

Linq to how to write like this?

Table is more than a pile of post and reply

CodePudding user response:

Sink? · · · · · · · · · · · · · · · · ·

CodePudding user response:

,,, probably in this way,
 from a post in 
Join in reply on a. b card id=b. card id
Orderby biggest reateTime item first-just
The select b;

CodePudding user response:

refer to the second floor is nu month god reply:
,,, maybe in this way,
 from a post in 
Join in reply on a. b card id=b. card id
Orderby biggest reateTime item first-just
The select b;



It will be found out more than the same post

CodePudding user response:

And you want to check the thread id
From a post in
Join in reply on a. b card id=b. card id
Where a. post id='you to query the post id'
Orderby biggest reateTime item first-just
The select b;

CodePudding user response:



The
reference killed, 4/f, matt, bull response:
add
do you want to check the thread idFrom a post in
Join in reply on a. b card id=b. card id
Where a. post id='you to query the post id'
Orderby biggest reateTime item first-just
The select b;


On the post ID? I am want to render out a list, you add a where clause is what meaning

CodePudding user response:

reference wilson2017 reply: 3/f
Quote: refer to the second floor is nu month god reply:

,,, probably in this way,
 from a post in 
Join in reply on a. b card id=b. card id
Orderby biggest reateTime item first-just
The select b;



It will be found out more than the same post

Finally destinct down heavy,

CodePudding user response:


 
Var result=(from a entities. In the Article
Orderby
(from c ment in entities.Com
Where c.a. rticleId==Anderson D
Select new
{
C.P ubDate
}). Max (p=& gt; Item first-just p.P ubDate)
Select new
{
Anderson, D,
A.T itle,
A.C ontent,
Amy polumbo ubDate,
LatestCommentDate=
(from c ment in entities.Com
Where c.a. rticleId==Anderson D
Select new
{
C.P ubDate
}). Max (p=& gt; P.P ubDate)
}). ToList ();
  • Related