Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6924671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:41:32+00:00 2026-05-27T10:41:32+00:00

I have a social networking website and I’m getting some difficulties to filter who

  • 0

I have a social networking website and I’m getting some difficulties to filter who can see the updates users post.

As in Facebook, I see all posts from my friends, even if I didn’t post anything.
I have these tables:

DiaryPosts table:

--------------------------------------
| ID | UserID | Content | UpdateTime |
--------------------------------------

Friends table:

--------------------------
| ID | UserID | FriendID |
--------------------------

Followers table:

----------------------------
| ID | UserID | FollowerID |
----------------------------

And I have this query that now it can’t filter anything:

var diaryPosts = (from d in db.DiaryPosts
                  orderby d.ID descending
                  select new DiaryPostsSet
                  {
                      PostID = d.ID,
                      Author = db.User.Where(m => m.ID == d.UserID).FirstOrDefault().Nickname,
                      Thumbnail = db.User.Where(m => m.ID == d.UserID).FirstOrDefault().Thumbnail,
                      AuthorComment = d.Content, 
                      UserID = d.UserID,
                      Time = d.UpdateTime }).Take(6).ToList();

I tried to write a where clause but it didn’t work.
Do you have any suggestions on how to write this query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:41:33+00:00Added an answer on May 27, 2026 at 10:41 am

    The answer is:

    //queries for diary Posts
            var myDiaryPosts = (from d in db.DiaryPosts
                                  join e in db.EstadosDeAlma
                                  on d.EstadosDeAlmaID equals e.ID
                                  join u in db.User
                                  on d.UserID equals u.ID
                                  where d.UserID == userset.ID
                                  select new DiaryPostsSet { 
                                      PostID = d.ID,
                                      EstadoDeAlmaID = e.ID,
                                      EstadoDeAlma = e.Title,
                                      Author = u.Nickname,
                                      Thumbnail = u.Thumbnail,
                                      UserID = u.ID,
                                      IsDuplicated = d.IsDuplicated,
                                      FriendID = d.FriendID,
                                      FriendName = u.Nickname,
                                      Time = d.UpdateTime,
                                      MessagesCount = d.FriendMessages.Count(m => m.DiaryPostsID == d.ID)
                                  });
    
            var friendsPosts = (from d in db.DiaryPosts
                                   join e in db.EstadosDeAlma
                                   on d.EstadosDeAlmaID equals e.ID
                                   join fr in db.Friends
                                   on d.UserID equals fr.FriendID
                                   where fr.UserID == userset.ID
                                   join u in db.User
                                   on fr.FriendID equals u.ID
                                   select new DiaryPostsSet
                                   {
                                       PostID = d.ID,
                                       EstadoDeAlmaID = e.ID,
                                       EstadoDeAlma = e.Title,
                                       Author = u.Nickname,
                                       Thumbnail = u.Thumbnail,
                                       UserID = u.ID,
                                       IsDuplicated = d.IsDuplicated,
                                       FriendID = d.FriendID,
                                       FriendName = u.Nickname,
                                       Time = d.UpdateTime,
                                       MessagesCount = d.FriendMessages.Count(m => m.DiaryPostsID == d.ID)
                                   });
    
            var followingsPosts = (from d in db.DiaryPosts
                                     join e in db.EstadosDeAlma
                                     on d.EstadosDeAlmaID equals e.ID
                                     join fl in db.Followers
                                     on d.UserID equals fl.UserID
                                     where fl.FollowerID == userset.ID
                                     join u in db.User
                                     on fl.UserID equals u.ID
                                     select new DiaryPostsSet
                                     {
                                         PostID = d.ID,
                                         EstadoDeAlmaID = e.ID,
                                         EstadoDeAlma = e.Title,
                                         Author = u.Nickname,
                                         Thumbnail = u.Thumbnail,
                                         UserID = u.ID,
                                         IsDuplicated = d.IsDuplicated,
                                         FriendID = d.FriendID,
                                         FriendName = u.Nickname,
                                         Time = d.UpdateTime,
                                         MessagesCount = d.FriendMessages.Count(m => m.DiaryPostsID == d.ID)
                                     });
    
            var diaryPosts = myDiaryPosts.Union(friendsPosts).Union(followingsPosts).OrderByDescending(d => d.Time).Take(6).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, So, I have a social networking website where users can share a post
I have multiple fields for social networking websites where users can enter their username
I'm building a social networking website. I have a table of Users. Each user
Im building a social networking website. A user can have pals and be able
I am a PHP beginner. I have developed a social networking website similar to
Can someone tell me why is this happening? I have created a social networking
Hi i have a social networking website. what i want it to do is
Android: I have a social networking application made by me, in which you can
I have a social networking website built upon the zend framework. My application also
I have a social networking site which is beginning to gain some momentum and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.