Anton
Mapping metadata
Is there a mapping library that doesn't only do mapping, but can also map a
PropertyInfo
to the associated PropertyInfo
in the other type? I wanted to propagate MaxLength from IModel of ef core to the dto's by backward mapping the entity back to the dto. I could do this by name only, but that obviously won't work the moment some name is different.5 replies
Process.Start print the command
I have an argument enumerable. There's a bunch of internal code that gets executed that produces the actual command that will be executed, but it doesn't seem to get saved anywhere. Is there a way to print the command that's going to be executed, besides copy-pasting the code that shell-escapes the argument enumerable and computing the command manually?
3 replies
ASP.NET Core same structure for all responses
I need a package that could wrap any response I return from the controller into a standard structure.
Kind of like this project https://github.com/proudmonkey/AutoWrapper
The problem with that project is that it doesn't modify the responses that Swagger sees.
I know I can take a shortcut by just returning the wrapped type from all endpoints, but that's just not plausible. I want it to work by default for everything.
So things I need in particular:
- Exception middleware that responds in json, with the same settings as configured for the response formatter. I don't really care about non-json, but ideally that should work too.
- Handle model binding errors, responding in the same standard format.
- The ability to handle custom exceptions, the ability for them to map to the model serialized.
- I want it to distinguish 400 from 500 automatically.
- The most important thing, I need it to affect swagger. The client should get the wrapped responses in swagger. If possible, the errors should be listed too.
- Has to be non-invasive, in the sense that it has to be handled at a central place, rather than duplicated for each handler.
I've tried doing some of this manually, but it's way more work than I anticipated.
1 replies
Use the model binding configuration to map PropertyInfo to its input name in Json / query param
I don't want to duplicate any logic that aspnet core does itself. I want to get the name of the json property or a property from whatever other source that it would bind to the given property. This ideally should work for property paths, so nested models can be interpreted correctly.
1 replies
VS Remove all bindings, then configure from scratch
Any real solution for this, besides clicking through their menus for each key individually? I found out by messing around that the base configuration gets imported from VSK files, available from the installation. But those are binary files. Any documentation on how to generate these? Or extract the bindings from them? Or a tool that does this?
The format of the keymap config file is just xml, where you can define a <Shortcut> or do a <RemoveShortcut> to remove a default. So if I could read the vsk file, I could in theory <RemoveShortcut> all the things that are there.
4 replies
❔ 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