adc90
adc90
CC#
Created by adc90 on 6/24/2024 in #help
Getting user credentials blazor
I have a blazor application I'm working on as part of a group. Our components are set as ServerPrerendered. I get my token back parse it into credentials and put that in a scoped service and get the info that way. Everything is golden util the circuit is disconnected, I store the token in localStorage, however I can't get it until OnAfterRenderAsync. However that's not how our application is set up. It expects the credentials to be there on OnInitializedAsync. Is there anyway to force a particular component to run first, render and be able to pull information from the Javascript and then put it back into the DI for subsequent components to use. Or would the application have to be reworked so that any credentials are retrieved OnAfterRenderAsync
1 replies
CC#
Created by adc90 on 9/24/2023 in #help
❔ Parsing an OData filter string
I have a project that has a mildly complex query requirement. I'm using radzen to build a filter and apply it to a view that acts as my data set. Most everything works fine however when I try to filter by DateTime I get an error Conversion failed when converting date and/or time from character string. This is coming from the end resulting query which directly below. Which has the time portion which I don't need/can't use that way.
SELECT
[a].[SellBy]
, [a].[ProductName]
FROM
[dbo].[Products] AS [a]
WHERE
[a].[SellBy] = '2023-02-05T00:00:00.0000000'
I'm very new to using expressions directly but in my code to convert the OData filter I have

if (IsNullableType(left.Type) && !IsNullableType(right.Type))
{
if(right is ConstantExpression offset)
{
if(offset.Value is DateTimeOffset dateTimeOffset)
{
DateTime? dateTime = dateTimeOffset.DateTime;
right = ConstantExpression.Constant(dateTime, typeof(DateTime?));
}
}
}
SELECT
[a].[SellBy]
, [a].[ProductName]
FROM
[dbo].[Products] AS [a]
WHERE
[a].[SellBy] = '2023-02-05T00:00:00.0000000'
I'm very new to using expressions directly but in my code to convert the OData filter I have

if (IsNullableType(left.Type) && !IsNullableType(right.Type))
{
if(right is ConstantExpression offset)
{
if(offset.Value is DateTimeOffset dateTimeOffset)
{
DateTime? dateTime = dateTimeOffset.DateTime;
right = ConstantExpression.Constant(dateTime, typeof(DateTime?));
}
}
}
Which gets me the below expression I pass directly to an entity framework where clause which
(Products.SellBy == 9/6/2023 12:00:00 AM)
(Products.SellBy == 9/6/2023 12:00:00 AM)
Then generates the problematic where clause
[a].[SellBy] = '2023-02-05T00:00:00.0000000'
[a].[SellBy] = '2023-02-05T00:00:00.0000000'
OData Query
SellBy eq 2023-09-06T00:00:00.000Z
SellBy eq 2023-09-06T00:00:00.000Z
There is more to the code including a section where I parse the OData query into a OData expression using an EDM which I'm not super familiar with. I left that out for brevity but I can post it if need be.
3 replies
CC#
Created by adc90 on 5/16/2023 in #help
❔ Authentication with blazor pre-rendered
I'm doing Authentication in blazor, we're using ProtectedBrowserStorage to store the user object. As such when I render components OnInitializedAsync I don't have access to the user object as it's stored client side. Is it the pattern to just do setup of a component OnAfterRenderAsync or is there a way to have access to the user object in OnInitializedAsync. I was thinking I could keep it in a server cookie but I'm not sure how to go about that.
7 replies
CC#
Created by adc90 on 4/18/2023 in #help
❔ Issues separating build artifacts in dev ops
I'm having trouble packaging some artificats in dev ops, I have an IO and an Presntation project. The presentation layer keeps being coppied into the API collateral as well as separately MainProject.sln - Model_Library.csproj - StaticUtilities.csproj - BlazorServerApp.csproj - APIWorkerForBlazorServerApp.csproj Desired goal * Artifacts Presentation/ BlazorServerApp.dll Resources wwwwroot, etc API/ APIWorkerForBlazorServerApp.dll Resources Actual Outcome * Artifacts Presentation/ BlazorServerApp.dll Resources wwwwroot, etc API/ APIWorkerForBlazorServerApp.dll Resources Presentation/ BlazorServerApp.dll Resources wwwwroot, etc Build steps are .NET CORE: Restore Build API .NET CORE: Publish to artificat directory ASP Publish to file location rx/API Build Presentation .NET CORE: Publish to artificat directory ASP Publish to file location rx/Presentation I'm thinking maybe the deploy web app step on I think publish is looking for appsettings.json so it grabs presentation collateral and shoves in inside my io collateral
4 replies