Saiyanslayer
Saiyanslayer
CC#
Created by Saiyanslayer on 10/25/2024 in #help
✅ Better way to set a property using linq?
I have this on a blazor component:
ValueChanged=@( async text => {
protocol.maxIterations = text;
await OnProtocolChanged(protocol);
})
ValueChanged=@( async text => {
protocol.maxIterations = text;
await OnProtocolChanged(protocol);
})
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:
ValueChanged=@(async text => await OnProtocolChanged(protocol.SetValue(x => x.maxIterations, text)
ValueChanged=@(async text => await OnProtocolChanged(protocol.SetValue(x => x.maxIterations, text)
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:
ValueChanged=@( async text => await OnProtocolChanged(protocol.GetType().GetProperty("Location"), text))
ValueChanged=@( async text => await OnProtocolChanged(protocol.GetType().GetProperty("Location"), text))
6 replies
CC#
Created by Saiyanslayer on 10/23/2024 in #help
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:
public static class TreeNavigation {
public static bool NodeExists(Root root, Node node){...}
}
public static class TreeNavigation {
public static bool NodeExists(Root root, Node node){...}
}
or a extension class like:
public static class TreeExtensions {
public static bool NodeExists(this Root root, Node node){...}
}
public static class TreeExtensions {
public static bool NodeExists(this Root root, Node node){...}
}
15 replies
CC#
Created by Saiyanslayer on 10/19/2024 in #help
How to find and update a record in a recursive model?
I have the following classes:
public sealed record NodeItem {
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
public List<NodeAttribute> Attributes { get; set; } = [];
public List<NodeItem> Children { get; set; } = [];
}

public sealed record NodeAttribute {
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}
public sealed record NodeItem {
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
public List<NodeAttribute> Attributes { get; set; } = [];
public List<NodeItem> Children { get; set; } = [];
}

public sealed record NodeAttribute {
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}
I'm using it in this code:
NodeItem? _node;
NodeItem? _selectedNode;

private void OnUpload(NodeItem node) {
_node = node;
}

private void OnNodeSelected(NodeItem node) {
_selectedNode = node;
}

private void OnNodeUpdated(NodeItem node) {
_selectedNode = node;
}
NodeItem? _node;
NodeItem? _selectedNode;

private void OnUpload(NodeItem node) {
_node = node;
}

private void OnNodeSelected(NodeItem node) {
_selectedNode = node;
}

private void OnNodeUpdated(NodeItem node) {
_selectedNode = node;
}
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
CC#
Created by Saiyanslayer on 10/17/2024 in #help
WPF TreeView Fails to load ItemsSource
The control
<UserControl x:Class="XMLViewer.Features.XMLViewer.XmlViewerComponent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:XMLViewer.Features.XMLViewer"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:XmlViewerViewModel}"
d:DesignHeight="600" d:DesignWidth="400" >

<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Items.Name}" />
<TreeView ItemsSource="{Binding Items}" Height="300">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:NodeItem}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<TextBlock Text="{Binding Text}" Foreground="Gray"/>
</StackPanel>
</ScrollViewer>

</UserControl>
<UserControl x:Class="XMLViewer.Features.XMLViewer.XmlViewerComponent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:XMLViewer.Features.XMLViewer"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:XmlViewerViewModel}"
d:DesignHeight="600" d:DesignWidth="400" >

<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Items.Name}" />
<TreeView ItemsSource="{Binding Items}" Height="300">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type local:NodeItem}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<TextBlock Text="{Binding Text}" Foreground="Gray"/>
</StackPanel>
</ScrollViewer>

</UserControl>
The viewmodel:
namespace XMLViewer.Features.XMLViewer;
public partial class XmlViewerViewModel : ObservableObject {
[ObservableProperty]
public NodeItem _items;

public XmlViewerViewModel() {
//testing treeview binding
var test = new NodeItem {
Name = "Test 1",
Children = new ObservableCollection<NodeItem> {
new NodeItem {Name = "Test 1.1" },
new NodeItem { Name = "Test 1.2" },
},
};

Items = test;
}

}
namespace XMLViewer.Features.XMLViewer;
public partial class XmlViewerViewModel : ObservableObject {
[ObservableProperty]
public NodeItem _items;

public XmlViewerViewModel() {
//testing treeview binding
var test = new NodeItem {
Name = "Test 1",
Children = new ObservableCollection<NodeItem> {
new NodeItem {Name = "Test 1.1" },
new NodeItem { Name = "Test 1.2" },
},
};

Items = test;
}

}
5 replies
CC#
Created by Saiyanslayer on 10/3/2024 in #help
MudBlazor DropContainer not triggering ItemDropped
I have the following MudBlazor MudDropContainer:
<!-- Dropzone for reorganizing and editing the Check Items -->
<MudDropContainer T="CustomDropItem" @ref="_dropContainer" Class="align-center justify-start"
Items=@_items
ItemPicked=@ItemSelected
ItemDropped=@ItemUpdated
ItemsSelector=@((item, dropzone) => item.Selector == dropzone)
ApplyDropClassesOnDragStarted
>
<ChildContent>
<MudDropZone T="CustomDropItem" Class="flex-grow-1" AllowReorder Identifier=@DropzoneId />
</ChildContent>
<ItemRenderer>
<MudStack [email protected] Class="ma-3">
<MudStack Row Class="py-n3 my-0" Style=@($"background-color: {context.Value.Colour};")
AlignItems="AlignItems.Center" Justify="Justify.FlexStart">

<MudPopover Class="mud-theme-default py-1 my-1" Open="@(_editIndex == context.SortOrder)"
AnchorOrigin="Origin.CenterLeft" TransformOrigin="Origin.CenterRight">

<!-- Content based on the type of TaskValue -->
</MudPopover>
</MudStack>
</MudStack>
</ItemRenderer>
</MudDropContainer>
<!-- Dropzone for reorganizing and editing the Check Items -->
<MudDropContainer T="CustomDropItem" @ref="_dropContainer" Class="align-center justify-start"
Items=@_items
ItemPicked=@ItemSelected
ItemDropped=@ItemUpdated
ItemsSelector=@((item, dropzone) => item.Selector == dropzone)
ApplyDropClassesOnDragStarted
>
<ChildContent>
<MudDropZone T="CustomDropItem" Class="flex-grow-1" AllowReorder Identifier=@DropzoneId />
</ChildContent>
<ItemRenderer>
<MudStack [email protected] Class="ma-3">
<MudStack Row Class="py-n3 my-0" Style=@($"background-color: {context.Value.Colour};")
AlignItems="AlignItems.Center" Justify="Justify.FlexStart">

<MudPopover Class="mud-theme-default py-1 my-1" Open="@(_editIndex == context.SortOrder)"
AnchorOrigin="Origin.CenterLeft" TransformOrigin="Origin.CenterRight">

<!-- Content based on the type of TaskValue -->
</MudPopover>
</MudStack>
</MudStack>
</ItemRenderer>
</MudDropContainer>
This was working in v6 but since I updated to v7, I cant get ItemDropped to trigger. The transaction keeps failing.
5 replies
CC#
Created by Saiyanslayer on 9/23/2024 in #help
✅ 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:
public class Structure {
public int Id;
public string Name;
public Property[] Properties; // each value to show/edit
public Structure[] Structures; // in the future, can also contain other Structure objects
}

public class Property<TValue> {
public int Id;
public string Name;
public T Value;
}
public class Structure {
public int Id;
public string Name;
public Property[] Properties; // each value to show/edit
public Structure[] Structures; // in the future, can also contain other Structure objects
}

public class Property<TValue> {
public int Id;
public string Name;
public T Value;
}
This would let me design a "Patient" object:
new Structure(Id:"1", Name:"Patient")
new Structure(Id:"1", Name:"Patient")
I could add properties:
var properties = {
new Property<string> {Id = 1, Name = "Patient Name", Value = "John Doe"},
new Property<string> {Id = 2, Name = "Patient Id", Value = "007"},
new Property<DateTime> {Id = 3, Name = "Patient Birthday", Value = "2024-09-22"}
}
var properties = {
new Property<string> {Id = 1, Name = "Patient Name", Value = "John Doe"},
new Property<string> {Id = 2, Name = "Patient Id", Value = "007"},
new Property<DateTime> {Id = 3, Name = "Patient Birthday", Value = "2024-09-22"}
}
What would be a good approach in EF Core to this? Table-Per-Hierarchy? How can I map the TValue generic properly?
31 replies
CC#
Created by Saiyanslayer on 9/19/2024 in #help
✅ How to handle complex Include in EF Core
I have the following entity:
public class PlanEntity : ISortable {
public int Id { get; set; }
public int SortPriority { get; set; }
public string Label { get; set; }
public string PlanId { get; set; }
public List<TaskSetEntity> TaskSets { get; set; } = [];

public DateTime? StartDate { get; set; }
public DateTime? ReadyToTreatDate { get; set; }
public List<ApplicationUser> Authors { get; set; } = [];
public SiteEntity TreatmentSite { get; set; }
public TechniqueEntity Technique { get; set; }
public RegionEntity TreatedRegion { get; set; }

public Plan ToPlan() => new Plan {
Id = Id,
Label = Label,
Authors = Authors.Select(x => x.UserName).ToArray(),
TaskSets = TaskSets.Select(x => new TaskSet {
Id = x.Id,
Label = x.Label,
Colour = x.Color,
IsHidden = x.IsHidden,
Checks = x.Checks.ToChecks()}).ToArray(),
TreatedSite = TreatmentSite is null ? new Site { Name = string.Empty } : TreatmentSite.ToSite(),
Technique = Technique is null ? new Technique { Name = string.Empty } : Technique.ToTechnique(),
TreatedRegion = TreatedRegion is null ? new Region { Name = string.Empty } : TreatedRegion.ToRegion(),
};
}

public static class PlanExtensions {
public static Plan[] ToPlans(this List<PlanEntity> entities) => entities
.OrderBy(x => x.SortPriority)
.Select(x => x.ToPlan())
.ToArray();
}
public class PlanEntity : ISortable {
public int Id { get; set; }
public int SortPriority { get; set; }
public string Label { get; set; }
public string PlanId { get; set; }
public List<TaskSetEntity> TaskSets { get; set; } = [];

public DateTime? StartDate { get; set; }
public DateTime? ReadyToTreatDate { get; set; }
public List<ApplicationUser> Authors { get; set; } = [];
public SiteEntity TreatmentSite { get; set; }
public TechniqueEntity Technique { get; set; }
public RegionEntity TreatedRegion { get; set; }

public Plan ToPlan() => new Plan {
Id = Id,
Label = Label,
Authors = Authors.Select(x => x.UserName).ToArray(),
TaskSets = TaskSets.Select(x => new TaskSet {
Id = x.Id,
Label = x.Label,
Colour = x.Color,
IsHidden = x.IsHidden,
Checks = x.Checks.ToChecks()}).ToArray(),
TreatedSite = TreatmentSite is null ? new Site { Name = string.Empty } : TreatmentSite.ToSite(),
Technique = Technique is null ? new Technique { Name = string.Empty } : Technique.ToTechnique(),
TreatedRegion = TreatedRegion is null ? new Region { Name = string.Empty } : TreatedRegion.ToRegion(),
};
}

public static class PlanExtensions {
public static Plan[] ToPlans(this List<PlanEntity> entities) => entities
.OrderBy(x => x.SortPriority)
.Select(x => x.ToPlan())
.ToArray();
}
how could I arrange this to elegantly grab the info from the dbContext?
114 replies
CC#
Created by Saiyanslayer on 9/19/2024 in #help
✅ 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
CC#
Created by Saiyanslayer on 9/12/2024 in #help
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
CC#
Created by Saiyanslayer on 9/5/2024 in #help
✅ EntityFramework Core trying to add Navigation Property that already exists
I'm getting this fault:
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: AspNetUsers.NormalizedUserName'.
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: AspNetUsers.NormalizedUserName'.
Entity class:
public class PlanEntity : ISortable {
public int Id { get; set; }
public int SortPriority { get; set; }
public string Label { get; set; }
public List<TaskSetEntity> TaskSets { get; set; } = [];

public DateTime? StartDate { get; set; }
public List<ApplicationUser> Owners { get; set; } = [];
public string[] Sites { get; set; } = [];
}
public class PlanEntity : ISortable {
public int Id { get; set; }
public int SortPriority { get; set; }
public string Label { get; set; }
public List<TaskSetEntity> TaskSets { get; set; } = [];

public DateTime? StartDate { get; set; }
public List<ApplicationUser> Owners { get; set; } = [];
public string[] Sites { get; set; } = [];
}
The owners property linked:
public class ApplicationUser : IdentityUser {
[Required, MaxLength(55)]
public string Name { get; set; }

}
public class ApplicationUser : IdentityUser {
[Required, MaxLength(55)]
public string Name { get; set; }

}
The model builder:
public static partial class ModelBuilderExtensions {
public static ModelBuilder AddPlanEntities(this ModelBuilder modelBuilder) {
modelBuilder.Entity<PlanEntity>()
.ToTable("RefactoredPlans")
.HasMany(x => x.TaskSets)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);

modelBuilder.Entity<PlanEntity>()
.ToTable("RefactoredPlans")
.HasMany(x => x.Owners)
.WithMany();

return modelBuilder;
}
}
public static partial class ModelBuilderExtensions {
public static ModelBuilder AddPlanEntities(this ModelBuilder modelBuilder) {
modelBuilder.Entity<PlanEntity>()
.ToTable("RefactoredPlans")
.HasMany(x => x.TaskSets)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);

modelBuilder.Entity<PlanEntity>()
.ToTable("RefactoredPlans")
.HasMany(x => x.Owners)
.WithMany();

return modelBuilder;
}
}
35 replies
CC#
Created by Saiyanslayer on 7/24/2024 in #help
✅ Using Params with Pattern Matching Switch statement
I have the following enums:
public enum SearchFilters {
None,
Active,
Overdue,
Archived
}
public enum SearchFilters {
None,
Active,
Overdue,
Archived
}
I want to link a modification to a query based on which enum you select by switch statement pattern matching:
public static class FilterExtensions {
public static IQueryable Filter(this IQueryable query, params SearchFilters[] filters) => filters switch {
[] => query,

_ => query,
};
}
public static class FilterExtensions {
public static IQueryable Filter(this IQueryable query, params SearchFilters[] filters) => filters switch {
[] => query,

_ => query,
};
}
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
CC#
Created by Saiyanslayer on 7/21/2024 in #help
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
CC#
Created by Saiyanslayer on 5/17/2024 in #help
Parameterized Unit Testing Class Types
I have the following test in xUnit:
[Fact]
public async Task QaTrackUrls_Should_Connect() {
var context = new QaTrackContext();
//var property = typeof(IModelBase).GetProperty("RequestUrl").GetValue(model).ToString();

var result = await context.GetAsync<ServiceEventModel>(ServiceEventsModel.RequestUrl);

Assert.True(result.IsSuccess);
}
[Fact]
public async Task QaTrackUrls_Should_Connect() {
var context = new QaTrackContext();
//var property = typeof(IModelBase).GetProperty("RequestUrl").GetValue(model).ToString();

var result = await context.GetAsync<ServiceEventModel>(ServiceEventsModel.RequestUrl);

Assert.True(result.IsSuccess);
}
I want to parameterize the test by giving classes (like ServiceEventsModel) instead of writing each one manually. so far, I've tried this:
[Theory]
[InlineData(typeof(ServiceEventsModel))]
public async Task QaTrackUrls_Should_Connect(Type model) {
var context = new QaTrackContext();
var property = typeof(IModelBase).GetProperty("RequestUrl").GetValue(model).ToString();

var result = await context.GetAsync<model>(property);

Assert.True(result.IsSuccess);
}
[Theory]
[InlineData(typeof(ServiceEventsModel))]
public async Task QaTrackUrls_Should_Connect(Type model) {
var context = new QaTrackContext();
var property = typeof(IModelBase).GetProperty("RequestUrl").GetValue(model).ToString();

var result = await context.GetAsync<model>(property);

Assert.True(result.IsSuccess);
}
but
context.GetAsync<model>
context.GetAsync<model>
gives an error
'model' is a variable but is used like a type
'model' is a variable but is used like a type
making it typeof(model) doesn't work and creates more errors.
3 replies
CC#
Created by Saiyanslayer on 5/13/2024 in #help
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,
var formula = "[value] + [value2]";
var formula = "[value] + [value2]";
I'm considering using a service to handle this
public List<Component> Components {get;set;}
...
public OnComponentInitializing(Component reference){
Component.Add(reference);
}

public OnComponentDisposal(Component reference){
Component.Remove(reference);
}
...

public double GetValue(string tag){
//converts tag into a label
//search list for a component that matches the label
//if found returns the value
}
public List<Component> Components {get;set;}
...
public OnComponentInitializing(Component reference){
Component.Add(reference);
}

public OnComponentDisposal(Component reference){
Component.Remove(reference);
}
...

public double GetValue(string tag){
//converts tag into a label
//search list for a component that matches the label
//if found returns the value
}
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
CC#
Created by Saiyanslayer on 5/7/2024 in #help
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
CC#
Created by Saiyanslayer on 4/13/2024 in #help
✅ Entity Framework One To Many: Adding to the dbContext and getting value '{Id: -2147482644}'
public async Task<Patient?> AddPatientAsync(Patient? patient) {
//validation
if (patient is null) { //no patient info
throw new NotImplementedException("Patient information is missing");
}

if (patient.Id < 0) {
throw new NotImplementedException("Patient already exists");
}

var result = await QueryOnContext(async context => {
var model = patient.ToModel();
await context.CheckGroups.AddRangeAsync(model.CheckGroups);


await context.Patients.AddAsync(model);
await context.SaveChangesAsync();
return await context.Patients.FirstOrDefaultAsync(p => p.Identifier == patient.Identifier && p.Name == patient.Name);
});

if (result is null) return null;
else return new Patient(result);
}
public async Task<Patient?> AddPatientAsync(Patient? patient) {
//validation
if (patient is null) { //no patient info
throw new NotImplementedException("Patient information is missing");
}

if (patient.Id < 0) {
throw new NotImplementedException("Patient already exists");
}

var result = await QueryOnContext(async context => {
var model = patient.ToModel();
await context.CheckGroups.AddRangeAsync(model.CheckGroups);


await context.Patients.AddAsync(model);
await context.SaveChangesAsync();
return await context.Patients.FirstOrDefaultAsync(p => p.Identifier == patient.Identifier && p.Name == patient.Name);
});

if (result is null) return null;
else return new Patient(result);
}
125 replies
CC#
Created by Saiyanslayer on 9/26/2022 in #help
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