asp.net - Entity Framework Core: issue with Contains method -


there simplified model of db:

public class chat { public icollection<applicationuser> users {get; set;} //nav property - represents participants of chat }  public class applicationuser : identityuser // represents net-identity user; not have references chats {...} 

so, in controller's class try chats such contain current user participant:

var user = getuser(); _context.chats.where(chat => chat.users.contains(user)).tolist(); 

this code throws exception:

you can not use type of expression ...applicationuser parameter's type "microsoft.entityframeworkcore.storage.valuebuffer" of method "boolean contains[valuebuffer](system.collections.generic.ienumerable`1[microsoft.entityframeworkcore.storage.valuebuffer], microsoft.entityframeworkcore.storage.valuebuffer)"

what problem here?

you need use any(), this

 var chatslist =_context.chats.where(chat => chat.users.any(u => u.id== user.id)).tolist(); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -