Saiyanslayer
✅ Better way to set a property using linq?
I have this on a blazor component:
to set a property, I had first set the property on the class and then feed that class to the update method.
I want to streamline the process to something similar to how EF Core sets a property in ExecuteUpdate:
looks like EF Core uses this SetPropertyCall class:
https://github.com/dotnet/efcore/blob/2e9e879746c3a75ad71b1c3732469c25f01bb8c7/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs#L3338
https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.query.setpropertycalls-1.setproperty?view=efcore-8.0
When I inspected the class on github, I couldn't find anything substantive that I could parse.
The best I could do is this:
6 replies
When to use a static helper class vs extension methods
When adding a static class, what criteria do you use to determine if it should be a helper class or an extension class?
For example, I have a recursive hierarchical data structure (has Children list of more of itself) and I want to write methods to help searching and iterating through it.
I could have a helper class like:
or a extension class like:
15 replies
How to find and update a record in a recursive model?
I have the following classes:
I'm using it in this code:
I thought I was sharing the reference, but that wasn't right. So either I figure out how to properly share the node through a pointer or I need to search through _node for the proper node to select or update.
Any suggestions? Any articles to help me understand this better?
16 replies
✅ Designing a configurable object in EF Core
Hi everyone!
My goal is to have an object for a web project where you can configure the fields it has:
This would let me design a "Patient" object:
I could add properties:
What would be a good approach in EF Core to this? Table-Per-Hierarchy? How can I map the TValue generic properly?
31 replies
✅ Design patterns or tools to for a changing database?
Hey everyone,
We have an EF core with Blazor project that is nearly ready for users to try out. My concern is how to update the database after reach release. Migrations will help with the database structure, but the existing data may need to be modified if a model changed.
How can I plan to address this? My initial thought is to make a console app to update the database for me, converting the old models to the new ones.
9 replies
How to Setup a remote Blazor server on Ubuntu
Hey all,
I'm working on a project and I'm getting overwhelmed with the options and need some guidance. I'm developing a Blazor project on my windows pc and trying to host it on an Ubuntu pc/server. It sometimes works, but I can't seem to get it to run as a service on the server. To help troubleshoot, I want to remotely attach to the process, but it's not being detected.
Right now, I'm publishing to folder (debug as opposed to release) and uploading the files to /var/project. I'd like to attach to the process at the very start, but I can't find how. Ideally, I'd like to be able to start debugging on my windows pc, but run on the Linux to see why it's failing.
Failing that, what would be a good setup for this? Should I explore docker instead?
12 replies
✅ Using Params with Pattern Matching Switch statement
I have the following enums:
I want to link a modification to a query based on which enum you select by switch statement pattern matching:
I can't find a syntax that works with the params keyword. I could do a foreach, but I'm tryign to improve my knowledge.
Is there a way to parse a switch pattern matching using an array of inputs?
31 replies
Using a library that requires STAThread in WPF with async
I'm using ESAPI, a library to access data from a medical database environment. To use it, the Main method needs to be in "single-threaded apartment" to access COM stuff. I want to include this in a WPF app, like a Entity Framework data context where I access it to search patients and apply search filters.
I'm struggling to find a way to do this. Should I have the "data context" like a class library and call it whenever I have a unit of work? Itd require a user to enter a password each time a search was done. I'd prefer a way to open the library and keep it open for quick searches.
Page 29 on here: https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.freelists.org/archives/vabene/01-2017/pdfutgYzAV_SF.pdf&ved=2ahUKEwj0js6SnreHAxU4DjQIHSw0D3wQFnoECCoQAQ&usg=AOvVaw0rPfu9Yo4WWWIvouNOc3so
4 replies
Parameterized Unit Testing Class Types
I have the following test in xUnit:
I want to parameterize the test by giving classes (like ServiceEventsModel) instead of writing each one manually. so far, I've tried this:
but gives an error making it typeof(model) doesn't work and creates more errors.
3 replies
Blazor Design: Expression Service That Depends on other Objects
For a Blazor project, I have a group of Expression components that calculates values based on text input and referencing each other for values. Users can use a tag like [value1] to reference other components. For example,
I'm considering using a service to handle this
What I'm worried about is if I have a directory page to search groups, I could end up loading dozens of this service and it could cause issues.
Question: do I have the right approach? Can I use a service to have a group of components to register with it to be easily searched and not have it balloon into a mess? Or should the service be like a singleton and have a single instance and the grouped expressions register and then handle referencing? If not, what would be a cleaner approach?
Alternatively, I was thinking of making a Parent reference in each of the expression components that would reference the group. Then the group would have a method to handle the expression.
5 replies
Database Design with EF Core: Two Entities share another Entity
I'm building a website to store Procedures, which contains multiple Steps. Both the procedure and the steps have Media entities, a wrapper for files stored on the server. The procedure has a single media (the header picture, one-to-one), but the steps have multiple images (many-to-many).
How can I handle the context setup?
7 replies
SignalR to SockJs [Answered]
Trying to used SignalR in C# to set up a websocket with a SockJS server (Octopi for a 3D printer). I'm using a Blazor server. Followed the tutorial on making a chat system, but struggling to find info on how to connect to external sites like a SockJS server. I've managed to get API calls working, but want learn more about responsive websites.
The goal is to make a webpage that grabs info from multiple servers, parses it, and displays it for the user in real time. We're starting with the 3D printer, but plan to expand to some proprietary software once I have a grasp on this.
I think I need a good tutorial or online course to understand more about SignalR: how to have a blazor server connect to another server's websocket, how to test and troubleshoot SignalR connection issues, how to set it up so an unresponsive server doesn't freeze a script or new webpage, etc. I'm open to suggestions for a better approach, but I'm comfortable in C#.
Octopi docs: https://docs.octoprint.org/en/master/api/push.html
SignalR tutorial - IAmTimCorey: https://www.youtube.com/watch?v=RaXx_f3bIRU
Udemy Course that I learned with: https://www.udemy.com/course/blazor-ecommerce/
48 replies