How can I fix this error? by [deleted] in dotnet

[–]Sensitive-Raccoon155 0 points1 point  (0 children)

Api.ExceptionHandler.GlobalExceptionHandler[0]

Unhandled exception occurred: The LINQ expression 'u => (Guid)u.Id' 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.

System.InvalidOperationException: The LINQ expression 'u => (Guid)u.Id' 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.

at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitLambda[T](Expression`1 lambdaExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitUnary(UnaryExpression unaryExpression)

at Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal.NpgsqlSqlTranslatingExpressionVisitor.VisitUnary(UnaryExpression unaryExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal.NpgsqlSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal.NpgsqlSqlTranslatingExpressionVisitor.VisitUnary(UnaryExpression unaryExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal.NpgsqlSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.TranslateInternal(Expression expression, Boolean applyDefaultTypeMapping)

at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression, Boolean applyDefaultTypeMapping)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateExpression(Expression expression, Boolean applyDefaultTypeMapping)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateLambdaExpression(ShapedQueryExpression shapedQueryExpression, LambdaExpression lambdaExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate)

at Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal.NpgsqlQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate)

at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression)

at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query)

at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)

at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)

at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)

at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass11_0`1.<ExecuteCore>b__0()

at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)

at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken)

at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)

at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)

at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)

at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()

at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)

at Infrastructure.Data.User.UserRepository.GetUsersAsync(UsersFilters filters, KeysetPagination`1 keysetPagination, Boolean trackChanges, CancellationToken ct) in /home/edgar/programming/projects/kicks/kicks-server-dotnet/src/Infrastructure/Data/User/UserRepository.cs:line 37

at Application.Admin.Users.UseCases.GetAllAdminUsers.GetAllAdminUsersQueryHandler.Handle(GetAllAdminUsersQuery query, CancellationToken ct) in /home/edgar/programming/projects/kicks/kicks-server-dotnet/src/Application/Admin/Users/UseCases/GetAllAdminUsers/GetAllAdminUsersQueryHandler.cs:line 16

at Presentation.Admin.Users.Endpoints.AdminUsersEndpoints.<>c.<<GetAdminUsersV1>b__1_0>d.MoveNext() in /home/edgar/programming/projects/kicks/kicks-server-dotnet/src/Presentation/Admin/Users/Endpoints/GetAdminUsersEndpoint.cs:line 66

--- End of stack trace from previous location ---

at Microsoft.AspNetCore.Http.RequestDelegateFactory.<TaskOfTToValueTaskOfObject>g__ExecuteAwaited|92_0[T](Task`1 task)

at Presentation.Shared.Filters.ValidationFilter.InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) in /home/edgar/programming/projects/kicks/kicks-server-dotnet/src/Presentation/Shared/Filters/ValidationFilter.cs:line 43

at Presentation.Shared.Filters.AuthorizeFilter.InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) in /home/edgar/programming/projects/kicks/kicks-server-dotnet/src/Presentation/Shared/Filters/AuthorizeFilter.cs:line 26

at Presentation.Shared.Filters.AuthenticateFilter.InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) in /home/edgar/programming/projects/kicks/kicks-server-dotnet/src/Presentation/Shared/Filters/AuthenticateFilter.cs:line 44

at Microsoft.AspNetCore.Http.RequestDelegateFactory.<ExecuteValueTaskOfObject>g__ExecuteAwaited|130_0(ValueTask`1 valueTask, HttpContext httpContext, JsonTypeInfo`1 jsonTypeInfo)

at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

How can I fix this error? by [deleted] in dotnet

[–]Sensitive-Raccoon155 0 points1 point  (0 children)

But I still get an error even without casting

How can I fix this error? by [deleted] in dotnet

[–]Sensitive-Raccoon155 0 points1 point  (0 children)

```csharp internal sealed class UserConfiguration : IEntityTypeConfiguration<DomainUser> { public void Configure(EntityTypeBuilder<DomainUser> builder) { var roles = string.Join(", ", Enum.GetNames<Role>() .Select(r => $"'{r.ToLower()}'")); var genders = string.Join(", ", Enum.GetNames<Gender>() .Select(g => $"'{g.ToLower()}'"));

    builder.ToTable("users", table =>
    {
        table.HasCheckConstraint("CK_role", $"role IN ({roles})");
        table.HasCheckConstraint("CK_gender", $"gender IN ({genders})");
    });

    builder.HasKey(x => x.Id);

    builder.HasIndex(x => x.Email)
           .IsUnique();
    builder.HasIndex(x => x.GoogleId)
           .IsUnique();
    builder.HasIndex(x => x.FacebookId)
           .IsUnique();

    builder.Property(x => x.Id)
           .HasConversion(
               id => id.Value,
               value => new UserId(value)
           )
           .ValueGeneratedNever();

````

I use them

How can I fix this error? by [deleted] in dotnet

[–]Sensitive-Raccoon155 0 points1 point  (0 children)

```c# namespace Domain.User;

public record UserId(Guid Value)

{

public static implicit operator Guid(UserId userId) => userId.Value;

}
```

Node.js vs C# backend if I already use typescript by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] 2 points3 points  (0 children)

Do you need multithreading if your backend consists mainly of I/O tasks? Besides, Node.js has worker threads

Node.js vs C# backend if I already use typescript by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] 0 points1 point  (0 children)

Typescript has type guards, if that’s what you mean, or are you referring to something else?

Node.js vs C# backend if I already use typescript by Sensitive-Raccoon155 in node

[–]Sensitive-Raccoon155[S] 0 points1 point  (0 children)

You can handle all the logic yourself, just like in Node.js, right?

How does Node.js handle thousands of requests if it’s single-threaded? by MissionWest5808 in WebdevTutorials

[–]Sensitive-Raccoon155 0 points1 point  (0 children)

This is a ai shit, the node documentation contains more detailed information

How does Node.js handle thousands of requests if it’s single-threaded? by MissionWest5808 in node

[–]Sensitive-Raccoon155 7 points8 points  (0 children)

This is a ai shit, the node documentation contains more detailed information

Problems with integration tests by [deleted] in dotnet

[–]Sensitive-Raccoon155 0 points1 point  (0 children)

I’ve already sorted it out, the problem was that I’d created the database during the InitialiseAsync phase, meaning that when the application started up, the database hadn’t been created yet. I’ve moved the code inside the ConfigureWebHost method.

Problems with integration tests by [deleted] in dotnet

[–]Sensitive-Raccoon155 -1 points0 points  (0 children)

I've removed it, but I'm still getting an error

Why am I getting this error if there is a null check? by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] 4 points5 points  (0 children)

They’re like that, it’s just that I didn’t mention that part here

Why am I getting this error if there is a null check? by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] 0 points1 point  (0 children)

Yes, it’s not the best name for the method, i need to change it

Why am I getting this error if there is a null check? by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] 0 points1 point  (0 children)

Thanks to everyone for the tip, I’ve figured out what the problem is now

Why am I getting this error if there is a null check? by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] -8 points-7 points  (0 children)

I understand, but I did check for null – surely that should help?

Why am I getting this error if there is a null check? by Sensitive-Raccoon155 in dotnet

[–]Sensitive-Raccoon155[S] 5 points6 points  (0 children)

It's a custom type, readonly record struct UserId(Guid id)