Anton
❔ Rider accepting completion deletes the next word
When I hit tab in Rider to accept a suggestion, it overwrites everything that comes after. Just like it does in this vid at the 15th second https://youtu.be/wCllU4YkxBk
How do I disable that?
16 replies
❔ Replacing joins to a table with a CTE in EF Core
Say I generate my sql with ef core. Is there a way to make it do joins on the CTE rather than the original table? So for example if I do a
Can I make the join with projects use a CTE, so it looks kinda like this:
Generating a query that's similar to this:
To be clear, what I want is for all joins with the projects table to be substituted for a join to a CTE.
Since I think EF Core cannot generate CTE's, is there a way to just force it to replace joins with the Projects table to
view
, which I would then append to the SQL query as text? I guess an idea is to replace the strings which reference the Projects table after it generates the SQL, but is there a way to do this at one higher level of abstraction?
Is my idea flawed, or is there a simpler way, you think?
The same can kinda be achieved with nested queries on all nested fields, but my problem with this is that it requires redoing the projections. Thinking of the Projects table as a view feels simpler in this case.3 replies
❔ HotChocolate with IQueryable, apply a required filter on the ef entity
Basically, I'm trying to find a way to configure an
IObjectFieldDescriptor
by adding a required argument to it, which should in turn apply a filter on the database entity. In this case, I'm adding a companyId
argument, and then applying the respective filter manually, before mapping. What should I do to configure this in a simpler way? Let me show you what I have and then what I mean by a better way.
This is what I have so far. Don't mind the FieldCollectionQuery
and UseBuiltinMiddleware
extension methods, they are there to set up the ef core stuff. The argument is the important bit right now.
4 replies
❔ Using automapper to update EF Core entities recursively
I'm trying the neat idea to try and make a generic create/update method which supports includes.
The first branch takes care of inserts. It takes requests of this form (currently doesn't check the nested ids, which it should):
It then maps this dto to a recursively tracked entity.
The second branch works with requests of this form, taking care of updates:
Currently I'm doing a bunch of things that are related to nested entities manually. I'm manually sorting the projects in reverse order, so that the projects with null key (projects to be inserted), end up at the end of the list. I'm then querying the entity from the db, checking if all of the projects meant for updating were found, and then I do a recursive copy of the dto into that entity. This maps all properties of the person and of each nested project. At least it should, what actually happens is it copies the null values over as well (see the mapper profile below). Then the tracker picks up on all of the newly mapped projects.
My question is, why does automapper map null properties even though it's set to ignore them, and is there a way to generalize this thing? The way I came up with doesn't seem overly complex, it's just not fully generic. I want the both the include filtering and the mappings to work independent of the level of depth of the objects.
21 replies
❔ Preventing a panel from overflowing + show scrollbar WPF
I have a situation like this
The problem is that the bottom panel overflows on the y axis. Solutions online suggest setting it to the width of the container like here https://stackoverflow.com/questions/47333220/wpf-scrollviewer-content-overflowing which I obviously can't do. How do I hide the overflow? I want it to take all available space on the Y axis, but no more than the screen height.
11 replies
❔ WPF a control to display an arbitrary object
It should support complex objects with multiple properties,
int
, string
, and IEnumerable
's of these. It's fine if it doesn't support nested collections. If the question is not clear, tell me to clarify it.9 replies
❔ WPF draw over other arbitrary controls
I want to draw over items contained in an
ItemsControl
, without wrapping the ItemsControl
into any sort of other object. Can anyone suggest a starting point / best practice? With my knowledge of WPF I don't know where to start solving this one.53 replies
❔ Is something like this possible with the default DI package?
So what I want to do is like this
How scopes work normally:
- global scope
- scope 1
* scoped service A
* scoped service B
- scope 2
* scoped service A (different instance)
* scoped service B (different instance)
What I want is to be able to resolve scoped services of the parent from a subscope, but create new services for some types in subscopes (are there even subscopes?)
- global scope
- scope 1
* service A
- scope 1.1
* service A resolved to the one of the parent
* service B
- scope 1.2
* different instance of service B
I've seen a lib allow this, but it's for Unity. They did it through custom scope classes.
Autofac might allow this too? I'm not sure.
4 replies
❔ Dotnet NuGet fetch packages with documentation
I can set
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
in the project file to enable copying the nuget packages on build. This makes the build in essence equivalent to publish. What I want, however, is for it to copy the xmls with the documentation instead, be it in publish or on build, I don't care. These xmls with documentation are located next to the dlls in the nuget packages. What property do I have to set to enable this?5 replies
❔ Multiple configurations with automapper
I have two automapper configurations, the first one is used to project entities to dtos when querying ef core normally or when just mapping objects, while the second one is for use with OData.
A while back I have asked about conventions of service configuration, and the answer was quite different from my intuitive solution.
So what I'm asking here is what's the conventional way of registering multiple automapper configurations? A factory by name or index does not seem to be officially supported by the public API, should I make a factory myself? Maybe some other library or option exists?
33 replies
❔ API DI advice
I want to implement a configurable injected class via an extension method, using the options system for the configuration. By looking through some code, I gathered that by doing
.Configure<Options>
you can chain configuration actions, which will execute when the container is being built. When the service that requires these options is instantiated, it would get the options snapshot from the service provider as a service.
However, what do I do if I still want to use this system, chaining the repeated actions, but I also want to register more services from these actions? How do I reference the service collection? Do I keep a reference to it in the options class? That's not it, right?
Basically, I need to register a few dependencies while the service is being configured from those actions.
Also, I've seen a library use ServiceDescriptor
added explicitly, but the code there is really funky, I don't understand how it works (it being encumbered with abstractions does not help).26 replies
❔ EF Core migrations
Is it normal that when I do
ef database update
with an unapplied migration, it tries applying all migrations from the start, even though the database already has all of the migrations but the last one? Like it even has a table with migration history so it should automatically detect which migrations haven't been applied yet. Or am I wrong?32 replies
❔ Azure Key Vault for local development
I need an oauth secret for development, but since storing secrets in source code is a bad practice, and it's clear to me why, I thought I'd use a service for this. The only free* service that I found is Azure Key Vault. Now I'm wondering how to connect it to the dev aspnet core application.
- I need it to be easily available on other machines, granted I'm logged in;
- It should prompt me to log in if it doesn't have the appropriate permissions to access the keys;
- I should be able to manage whom I entrust the keys, so I should be able to authorize specific users manually, given I have access to the account that created the vault.
The info I've found so far either throws around various authentication terms, like the RBAC, the active directory, the managed identity, which I haven't worked with and hence I don't know which one I need if any. Most tutorials talk about deploying to Azure, which I don't care about, I only need development access to the vault.
Now how I see the ideal experience, is that on restore of the project a command is run, which prompts authentication if required and copies the secrets into the secret manager storage for the project. https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-7.0&tabs=windows#how-the-secret-manager-tool-works Then this command could be rerun as needed to sync the keys manually. The app then would just use this config and not care about azure.
* with the student pack
2 replies
❔ Authorization convention for requests other than get
I want to require authorization for all endpoints that accept request types other than get. By looking through the source code, I've only found
AuthorizeFilter
. Should I be conditionally adding filters based on the existent filters? but IAuthorizeData
is not a metadata filter, so it won't even be in that list. Should I make a custom X (I can't find the type that has to do with policy requirement extraction)?2 replies