C
C#5mo ago
BekirK

OData filtering

Hi everyone, I want to ask you something about OData, I have roles for a user. And I separate these roles with ",". For example, there are roles such as; user_1: "test_1, test_2" user_2: "test_1" user_2: "test_2, test_4" I use OData when listing these roles. There is a filtering process on the FE side. However, since there is more than one role separated by commas, it gives the following error: objA: (object)EF.Property<Guid?>(u, "Id"), \r\n objB: (object)EF.Property<Guid?>(u0, "UserId")))\r\n . Any() ? string.Join(\r\n separator: ",", \r\n values: DbSet<UserRole>()\r\n .Where(u1 => !(u1.IsDeleted))\r\n .Where( u1 => EF.Property<Guid?>(u, "Id") != null && object.Equals(\r\n ) How do you think I can do the filtering? When I filter as "test_2" I want user_1 and user_2 to appear.
2 Replies
WEIRD FLEX
WEIRD FLEX5mo ago
objA: (object)EF.Property<Guid?>(u, "Id"),
objB: (object)EF.Property<Guid?>(u0, "UserId").Any()
? string.Join(
separator: ",",
values: DbSet<UserRole>()
.Where(u1 => !(u1.IsDeleted))
.Where(u1 => EF.Property<Guid?>(u, "Id") != null && object.Equals()
objA: (object)EF.Property<Guid?>(u, "Id"),
objB: (object)EF.Property<Guid?>(u0, "UserId").Any()
? string.Join(
separator: ",",
values: DbSet<UserRole>()
.Where(u1 => !(u1.IsDeleted))
.Where(u1 => EF.Property<Guid?>(u, "Id") != null && object.Equals()
if this is the correct formatting maybe we still need some part of the message?
BekirK
BekirK5mo ago
Error Message: errors": ["The LINQ expression 'DbSet<User>()\r\n .Where(u => !(u.IsDeleted))\r\n .Where(u => DbSet<UserRole>()\r\n .Where(u0 => !(u0.IsDeleted))\r\n .Where(u0 => EF.Property<Guid?>(u, "Id") != null && object.Equals(\r\n objA: (object)EF.Property<Guid?>(u, "Id"), \r\n objB: (object)EF.Property<Guid?>(u0, "UserId")))\r\n .Any() ? string.Join(\r\n separator: ",", \r\n values: DbSet<UserRole>()\r\n .Where(u1 => !(u1.IsDeleted))\r\n .Where(u1 => EF.Property<Guid?>(u, "Id") != null && object.Equals(\r\n objA: (object)EF.Property<Guid?>(u, "Id"), \r\n objB: (object)EF.Property<Guid?>(u1, "UserId")))\r\n .Join(\r\n inner: DbSet<Role>()\r\n .Where(r => !(r.IsDeleted) && r.PropertyId == 00000000-0000-0000-0000-000000000000 || (Guid?)r.PropertyId == (Guid?)c8109bdf-1d8e-42c9-bc9d-be70fb1333bb), \r\n outerKeySelector: u1 => EF.Property<Guid?>(u1, "RoleId"), \r\n innerKeySelector: r => EF.Property<Guid?>(r, "Id"), \r\n resultSelector: (o, i) => new TransparentIdentifier<UserRole, Role>(\r\n Outer = o, \r\n Inner = i\r\n ))\r\n .Select(u1 => u1.Inner.Description)) : null == __TypedProperty_0)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information."]
Client vs. Server Evaluation - EF Core
Client and server evaluation of queries with Entity Framework Core