Linq Many to many in Entity Framework core

Linq Many to many in Entity Framework core

I have classes for building many to many relationships.

I have classes for building many to many relationships.

public class Chat 
{
    [Key]
    public Guid Id { get; set; }
    public ICollection<ApplicationUserChat> UserChats { get; set; }
}

public class ApplicationUserChat { [Required] public string UserId { get; set; } public ApplicationUser User { get; set; }

public Guid ChatId { get; set; }
public Chat Chat { get; set; }

}

public class ApplicationUser : IdentityUser {
public ICollection<ApplicationUserChat> UserChats { get; set; }
}

For example, I have a user1 and user2

  1. I need to Select chats for user1 where chat contains a user2
  2. I need to select chat for user1 where chat contains a user2 and not contains another users (like one chat contains only 2 participants)
  3. How I can do this in EF Core?


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Encrypt Password in Login Form with ASP.NET MVC and Identity framework

LIKE | COMMENT | SHARE | SUBSCRIBE In this video, I will demo how to create Encrypt Password in Login Form with ASP.NET MVC and Entity Framework. Subscribe &...

Delete role in asp net core identity framework

LIKE | COMMENT | SHARE | SUBSCRIBE In this video, I will show you How to delete role name by using identity framework. Source code link : https://gitlab.com/...

User Role Report in asp.net core [part 01] || LINQ

LIKE | COMMENT | SHARE | SUBSCRIBE In this video we will discuss how to join multiple table using LINQ (Language Integrated Query). Source code link : https:...