Naster
Naster
CC#
Created by Naster on 12/10/2024 in #help
How to implement routing with slug variable
In Blazor, I'm looking for a way to implement routing from a slug e.g. myapp.com/{slug}. Something similar to what Github is doing e.g. https://github.com/dotnet/roslyn. Each organization in my app has a dedicated unique slug to be able to bookmark the url for easy access. I have an API that needs an x-organization-id in the header that represent the current organization, matching the slug. My api client is configured to use the blazor server as a proxy when the interactivity is WASM and calls the api directly when the interactivity is server. This part is working great. Should I do all my calls with a slug in the url from Blazor WASM -> Blazor Server (Proxy) -> API or with a translation from slug to id from the proxy to API? I have the feeling it is better for the API to used an ID. How should I do this?
1 replies
CC#
Created by Naster on 6/28/2024 in #help
✅ What are repetitive tasks that you do in a web interface that you would automate?
What is the task? How much hours would you save per week?
2 replies
CC#
Created by Naster on 4/25/2023 in #help
✅ Generic nullable type
I have an interface ITypelyValue<TValue, TTypelyValue> that let me create validated value objects. I need to convert theses types using a ValueConverter for EF Core.
public class TypelyValueConverter<TValue, TTypelyValue> : ValueConverter<TTypelyValue, TValue>
where TTypelyValue : ITypelyValue<TValue, TTypelyValue>
{
public TypelyValueConverter()
: base(
v => v.Value,
v => TypelyValue.From<TValue, TTypelyValue>(v))
{
}
}
public class TypelyValueConverter<TValue, TTypelyValue> : ValueConverter<TTypelyValue, TValue>
where TTypelyValue : ITypelyValue<TValue, TTypelyValue>
{
public TypelyValueConverter()
: base(
v => v.Value,
v => TypelyValue.From<TValue, TTypelyValue>(v))
{
}
}
This works fine for value types. e.g. public struct MyValueObject : ITypelyValue<int, MyValueObject>{...}. With an entity :
public class MyEntity
{
public MyValueObject Prop1 {get; set;} //ok
public MyValueObject? Prop2 {get; set;} //Error
}
public class MyEntity
{
public MyValueObject Prop1 {get; set;} //ok
public MyValueObject? Prop2 {get; set;} //Error
}
When I make my value object nullable, the property becomes a reference type and I'm confused of how I can handle saving a null value to the database with the type converter. Other ref: https://github.com/adampaquette/Typely/blob/main/src/Typely.Core/ITypelyValue.cs
2 replies