Ole (ping please)
Deserializing binary data
I have the following structures:
I am curious, what is the best way to serialize this? Currently I simply read it into a stream and reads one attribute at the time. Coming from a c++ background this feels highly inefficent.
When I try to google the problem I dont get a lot of new results, but I suspect there might be some changes to the language in the last 10 years which have improved tasks like this?
16 replies
❔ Selecting child tables using EF Core
I have the following class hierarchy
Enterprise => Company => Site => Department => Container
What would be the most efficent way of selecting a container with a given ID using ef core. In my DbContext I only have a reference to the root object, Enterprise
Currently I have this mess:
10 replies
❔ Getting all instances from a IServiceScope
I have a callback system that I want to ensure all subscribers are removed from when a dependency scope is destroyed.
To achive this I want to itterate over all instanciated class and unregister them.
But I am struggeling with getting all created instances from the IServiceScope. I cant cast to ServiceProviderEngineScope, as that is a sealed internal class.
How does one normally access this information?
29 replies
❔ Help with Action syntax for event handler system
I am trying to add a basic event system to my program and would like the syntax to be something like this:
Ideally there is no need for a baseclass or interface. All that should be needed is for the function passed as an action to take the event type as an argument.
I have the following implmentation for the registration:
I would very much like the register syntax to be like this:
but I struggle with how to achive this, and I am not entirely sure if its possible?
7 replies
❔ Setting tab name dynamically
I am trying to set the header for a tab in a tabcontroll based on the content, but struggle to make it work.
I have the following wpf layout:
CurrentEditorsList is a UserControl where the DataContext is set to an object which has an object DisplayName.Value.
I have also tried DataContext.DisplayName.Value, but it also does not work.
How do I reference the content of the user control in this context?
2 replies
❔ Getting the last data registration time for multiple locations
I have the following Sql table, which I access using ef core.
I need to find the last registration date for each different location. Currenetly I do the following:
This is obviously not great. What would be the propper way to do this?
15 replies
❔ Sorting a list of objects into a tree structure
I have a set of objects that looks roughly like this:
class Item
{
public uint Id;
public uint ParentId;
}
To visualize the data I want to sort the data into a graph. Is there a built in way of doing this in C#?
For the actual visualisation I am happy with just viewing it in the debugger. The reason for asking the question instead of just doing it is that I want to get better at using built in functionality. I string.Join(", ", array) was a game changer for example8 replies
❔ How to handle migration with column changes in Ef Core code first?
I need to change a table which is already in production.
Specifically I need to change a field which is currently an integer which represents a week number.
I now need to change it to a proper datatime.
Ideally I would like to do something like this:
1. Add a new column to the table - StartDate
2. Add some code to the migration Up file which runs through all the instances of that table and reads the StartWeek column and writes to the StartDate
3. Remove the StartWeek column
What is the best practice for handling this?
7 replies
❔ Infer the second generic type from input data
I am wondering if its possible to write the following code in some way that it works like I want it to.
My goal is to specify a class and an argument. The function should then create the class and pass the argument to it.
8 replies