Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    dimtabu
    @taburetkin

    Hi guys,
    here is some t-sql query i have:

    declare @dmin datetime = cast('2022-05-01' as datetime);
    declare @dmax datetime = cast('2022-06-01' as datetime);
    
    with core as (
        select 
            productid, AmountInStoreBefore, AmountInStoreAfter 
            , ROW_NUMBER() over (partition by productid order by created asc) rn
        from ProductBatchTransfers
        where 
            created between @dmin and @dmax
    )
    
    select 
        core.productid, core.AmountInStoreBefore,
        core2.AmountInStoreAfter
    
    from core
    
    inner join (
        select 
            productid, max(rn) edgern 
        from core
        group by productid
    ) grp 
        on core.productid = grp.productid
    
    inner join core core2 
        on core.productid = core2.productid and grp.edgern = core2.rn
    
    where 
        core.rn = 1

    i think its prety self explanatory, so, the questions are:
    1) is there a way to create something similar with entityframework ?
    we are talking about .net462
    2) Is query good enough or i can improve it somehow (i am realy not enough good in t-sql)

    Isobel Cullen
    @isobel-cullen
    When calling AuthorizationHandlerContext.Fail is there a way to return the failure message to the client? Nothing that I have tried or found online has worked.
    Muhammad Waleed Hafeez
    @Muhammad-Waleed-Hafeez
    has anyone used NextJs with asp.net core for web development?
    dimtabu
    @taburetkin

    who can tell me what workaround may be for publlicating .net6 project in docker?
    i have this structure of folders

    dotnet/
    --shared-solutions/
    ----common-solution/
    ------shared-project-a/
    ------shared-project-b/
    --client-a/
    -----project-solution/
    -------shared
    ---------shared-project-a
    -------web-api/
    ---------Docker.file

    i am trying to publish web-api project from project-solution
    the project-solution has reference to common-solution/shared-project-a
    and web-api has reference to shared/shared-project-a
    debugging in docker works like a charm but publishing fails with error: the imported project was not found '/shared-solutions/common-solution/shared-project-a' confirm that the expression in the import declaration '../../../shared-solutions/common-solution/shared-project-a' is correct

    i think this is because of docker context does not have shared-solutions/**/* but i am not sure. it strange that debugging works. i thought that docker context builded with respect to shared projects out of solution.

    does vs2022 can handle such scenarios? i mean when you build something with links to shared projects laying out of solution folder?

    Thomas Ottenhus
    @glatzert

    A contributor from the AspNetCore Docs pointed me here, and I hope I might shed some light on a problem I've encountered.
    AspNetCore 7 will embrace the ProblemDetails usage (which is good).
    But there's no guidance about using the ProblemDetails class in client code.
    Referencing the Http.Abstractions DLL in e.g. a Blazor-WASM project seems odd.

    Implementing a "copy-cat" class seems unneccesary.
    What's the approach people are using? (Perhaps even in combination with nswag client generation and shared Models)

    sechelé delaruse
    @vigouredelaruse
    re: cors requests with attached bearer tokens - i'm trying to optimize/eliminate the preflight time for such requests and i want to know if the following code is synononymous with allow any origin - please advise
            opts.AddDefaultPolicy(builder =>
            {
                builder
                     .AllowAnyHeader()
                     .AllowAnyMethod()
                     .AllowCredentials()
                     .SetIsOriginAllowed(hostname => true); // the developer friendly 'local' setting (outside the librar)
                     // .WithOrigins("https://localhost:4200", "http://localhost:4200");
    
            });

    Hi. Question about .net AOT here, specifically MAUI on android.

    If my understanding of AOT is correct, the assemblies are already compiled to native codes and I can confirm this with all the .so file in the apk.

    However when doing performance check with dotnet-trace, I still see a lot of JIT being done killing the startup time of the app.
    The apk is built for AOT everything in release mode with

    <PropertyGroup Condition="'$(Configuration)' == 'Release'">
            <RunAOTCompilation>true</RunAOTCompilation>
            <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
        </PropertyGroup>

    But yet there is a lot of System.Private.CoreLib!System.Runtime.CompilerServices.RuntimeHelpers.CompileMethod(object) in the call stack taking good amount of time.

    I attach my speedscope json file.

    sake402
    @sake402
    dotnet --version
    6.0.400
    Matt Boyle
    @oriboyle_twitter
    Hi everyone, I'm learning ASP.NET core and I'm running into an issue with dependency injection. I have an model class, Game, and a public DbSet<Game> Games { get; set; } property on my DbContext. I've requested an ILogger<Game> in the constructor of the Game class. When I try to use the collection, I get an error reporting that the logger parameter cannot be bound. Constructor DI like this works fine in a controller - can I not use it in an EF core model?
    I've been reading documentation and googling, but I can't seem to find a clear message around where/when DI can be used. Ultimately, I want to inject my own singleton service into this class. That also wasn't working so I was testing ILogger first to rule out an issue with my service installation.
    Alberto Passalacqua
    @AlbertoPa
    you are trying to define a logger using the same type being defined and constructed?
    Matt Boyle
    @oriboyle_twitter
    Indeed. And as you say that, it sounds problematic. :) I'm just copying a pattern I had in a controller which does work (e.g. public GamesController(DatabaseContext context, IMapper mapper, ILogger<GamesController> logger)).
    Alberto Passalacqua
    @AlbertoPa
    ILogger does not need a type
    there is an untyped version
    Matt Boyle
    @oriboyle_twitter
    Ok, I'll try again sans type.
    Still failing unfortunately.
    System.InvalidOperationException: No suitable constructor was found for entity type 'Game'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'logger' in 'Game(ILogger logger)'.
    Alberto Passalacqua
    @AlbertoPa
    without seeing your code...
    Matt Boyle
    @oriboyle_twitter
    I can copy more in, one second. Thanks for the help!
    AlbertoPa @AlbertoPa is headed out
    Matt Boyle
    @oriboyle_twitter
    (In Game.cs)
        public Game(ILogger logger)
        {
            logger.LogInformation("Here");
        }
    (In DatabaseContext.cs)
    public class DatabaseContext : DbContext
    {
        public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
    
        public DbSet<Game> Games { get; set; } = null!;
    (In Program.cs)
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddControllers();
    builder.Services.AddDbContext<DatabaseContext>(opt =>
        opt.UseInMemoryDatabase("Database"));
    Matt Boyle
    @oriboyle_twitter
    Been debugging a bit, and re-reading that error, it seems like it's attempting to fill in properties of the Model (record values) rather than resolving a service..
    Ok, and now I'm finding better search results.. Sounds like this is possible, with some work, but it's antipattern I should avoid. Thanks anyway folks!
    dimtabu
    @taburetkin
    Hi guys
    i have a published (production) web site (.net472)
    also there is my local copy of this web site.
    i am using SmtpClient to send messages from this website
    both local and production web sites has same smtp configuration but production can not send message while local succesfully send messages.
    i am struggling to determine the reason.
    client.Send(email) throws an exception with message something like: The attempt to establish a connection was unsuccessful, because the desired response was not received from another computer in the required time, or an already established connection was terminated due to an incorrect response from an already connected computer
    i've checked tls config - both have the same ssl3, tls.
    smtp server is available from production network.
    don't know what to check else, any thoughts?
    dimtabu
    @taburetkin
    ok. i've solved this.
    sake402
    @sake402
    Hi.
    Is anyone using hotrelaod here. I mean doest it ever work for you.
    Zavada Serhii
    @zavada-serhii
    Hi. Could you tell me if there is any way to find out in runtime how many active sessions are currently on Kestrel.