Amos
Amos
CC#
Created by Amos on 1/25/2023 in #help
✅ Blazor WASM - Dynamic Open Graph Protocol
I'm looking for a bit of help/suggestions with a dynamic OGP using Blazor WASM. Since it's a SPA, I'm not exactly sure how to approach a more page/description dynamic OGP embed. For example, if a user navigates and hotlinks a profile, I'd like the OGP embed to include the updated title page, and a more customised embed including their profile name and some more relevant information.
9 replies
CC#
Created by Amos on 1/25/2023 in #help
✅ Blazor WASM - Dynamic Open Graph Protocol
I'm looking for a bit of help/suggestions with a dynamic OGP using Blazor WASM. Since it's a SPA, I'm not exactly sure how to approach a more page/description dynamic OGP embed. For example, if a user navigates and hotlinks a profile, I'd like the OGP embed to include the updated title page, and a more customised embed including their profile name and some more relevant information.
23 replies
CC#
Created by Amos on 1/2/2023 in #help
❔ Blazor Hosted - Client datatable with large dataset
I have a table component (using MudBlazor) which accesses the server-side API endpoint and pulls (currently) around 130k records. As you can imagine, too much for a client. 🙂 I need help and examples if possible on how I can implement client/server table pagination. Any help is appreciated, thanks! https://mudblazor.com/components/table#server-side-filtering,-sorting-and-pagination (I followed this, but I don't quite understand its implementation for server-side, it seems all client-side to me.)
19 replies
CC#
Created by Amos on 12/25/2022 in #help
✅ EFCore Nullability and Circular References
I have 2 tables which have FK's to each other due to the relationship. I'm trying to add some seed data for a profile that needs to be created on initialisation.
EFUser(single - FK to most recent EFAlias) -> EFAlias(many - FK to EFUser)

EFAlias(many - FK to EFUser) -> EFUser(single - FK to most recent EFAlias)
EFUser(single - FK to most recent EFAlias) -> EFAlias(many - FK to EFUser)

EFAlias(many - FK to EFUser) -> EFUser(single - FK to most recent EFAlias)
I've tried two ways... 1. I'm getting an SQL 19 error which is a expected field that isn't provided (NULL). If I set the FK in EFAlias to Nullable with ?, then the field in the database isn't populated (which makes sense). However, with the above scenario if I ever lookup the seeded user from their EFAlias, FK to EFUser isn't populated. So it's not possible. 2. If I remove the Nullable statement in the property and provide the UserId and AliasId in the seed data, the migration fails due to Circular Reference (which again, makes sense) Is there a way I can both have each field populated and required (not nullable)? Prefixed tables with EF just to make it a little clearer. SEED: (2nd example - circular reference)
var adminAlias = new EFAlias
{
Id = 1,
EntityId = 1,
UserName = "IW4MAdmin",
IpAddress = "0.0.0.0",
Changed = DateTimeOffset.UtcNow
};

var adminEntity = new EFEntity
{
Id = 1,
CurrentAliasId = 1,
ProfileIdentity = "0:UKN",
Reputation = 0,
Infractions = new List<EFInfraction>()
};
var adminAlias = new EFAlias
{
Id = 1,
EntityId = 1,
UserName = "IW4MAdmin",
IpAddress = "0.0.0.0",
Changed = DateTimeOffset.UtcNow
};

var adminEntity = new EFEntity
{
Id = 1,
CurrentAliasId = 1,
ProfileIdentity = "0:UKN",
Reputation = 0,
Infractions = new List<EFInfraction>()
};
MODEL: (1st example - missing FK in EFAlias)
public int? EntityId { get; set; }
[ForeignKey(nameof(EntityId))] public EFEntity? Entity { get; set; } = null!;
public int? EntityId { get; set; }
[ForeignKey(nameof(EntityId))] public EFEntity? Entity { get; set; } = null!;
66 replies
CC#
Created by Amos on 12/14/2022 in #help
❔ Database Models and Tracking Reference
16 replies
CC#
Created by Amos on 12/11/2022 in #help
✅ Determining a Configuration Type
I'm running into a problem trying to access a specific property of a configuration type. I'm unsure if I'm having this problem due to the layout of my configuration or just part of C# I've not yet ran into. 🙂 I have an enum VoteType with 4 members, Kick, Ban, Map, Skip, Mute. I have a configuration for those relevant types KickConfiguration, BanConfiguration, MuteConfiguration etc these configurations inherit from BaseConfiguration Each 'TYPE'Configuration has a inherited property Cooldown. In my code, I need to access this cooldown specific to the vote type. How do I do this? In the method I need it, I have access to the VoteType enum. I'm not sure if there's a way to infer the configuration type from this enum? The full property 'path'(?) is...
_configuration.VoteConfiguration.BanConfiguration.Cooldown;
_configuration.VoteConfiguration.KickConfiguration.Cooldown;
// etc
_configuration.VoteConfiguration.BanConfiguration.Cooldown;
_configuration.VoteConfiguration.KickConfiguration.Cooldown;
// etc
Let's say I've got this method..
public static TimeSpan Cooldown(VoteType voteType)
{
return new TimeSpan( /* What do I put here to get the per-voteType relevant cooldown?*/ );
}
public static TimeSpan Cooldown(VoteType voteType)
{
return new TimeSpan( /* What do I put here to get the per-voteType relevant cooldown?*/ );
}
21 replies