wijnand
wijnand
CC#
Created by wijnand on 2/21/2023 in #help
❔ SQL RAW to LINQ question
Greetings, I have a SQL query that was given to me but I was wondering if this query could be simplefied into a LINQ query. A lot of the program was made during the time of EF core 1.0. we have a ton of SQL RAW.
const string query = @"
WITH cteRowNumber AS (
SELECT [PersonalFieldBoundaryId]
,[FieldBoundaryId]
,[ParticipantId]
,[Start]
,[RedUpper]
,[OrangeUpper]
,[GreenUpper]
,[GreenLower]
,[OrangeLower]
,[RedLower]
,row_number() OVER(PARTITION BY [FieldBoundaryId] ORDER BY [Start] DESC) AS RowNum
FROM PersonalFieldBoundaries
WHERE [Start] <= {1} AND [ParticipantId] = {0}
)
SELECT [PersonalFieldBoundaryId]
,[FieldBoundaryId]
,[ParticipantId]
,[Start]
,[RedUpper]
,[OrangeUpper]
,[GreenUpper]
,[GreenLower]
,[OrangeLower]
,[RedLower]
FROM cteRowNumber
WHERE RowNum = 1
";
const string query = @"
WITH cteRowNumber AS (
SELECT [PersonalFieldBoundaryId]
,[FieldBoundaryId]
,[ParticipantId]
,[Start]
,[RedUpper]
,[OrangeUpper]
,[GreenUpper]
,[GreenLower]
,[OrangeLower]
,[RedLower]
,row_number() OVER(PARTITION BY [FieldBoundaryId] ORDER BY [Start] DESC) AS RowNum
FROM PersonalFieldBoundaries
WHERE [Start] <= {1} AND [ParticipantId] = {0}
)
SELECT [PersonalFieldBoundaryId]
,[FieldBoundaryId]
,[ParticipantId]
,[Start]
,[RedUpper]
,[OrangeUpper]
,[GreenUpper]
,[GreenLower]
,[OrangeLower]
,[RedLower]
FROM cteRowNumber
WHERE RowNum = 1
";
14 replies
CC#
Created by wijnand on 2/17/2023 in #help
Calling Buildserviceprovider from application code results in additional copy of singleston services
Greetings, I am currently working on a very old .NET 1.1 core project in .NET 6 and I saw a warning that i found concerning but i am not entirely sure how i can fix this . The guides I found seem to give me the impression this entire function is wrong. services.AddMvc(options => { // Unsure if this works. If it does, it doesn't get the strings from the resource file. // Test when certain this must be triggered var F = services.BuildServiceProvider().GetService<IStringLocalizerFactory>(); var L = F.Create(typeof(ModelBindingMessages)); options.ModelBindingMessageProvider.SetValueIsInvalidAccessor( (x) => L["De waarde {0} is niet geldig voor veld {1}."]); options.ModelBindingMessageProvider.SetValueMustBeANumberAccessor( (x) => L["Het veld {0} moet een nummer zijn."]); options.ModelBindingMessageProvider.SetMissingBindRequiredValueAccessor( (x) => L["Er is geen waarde gegeven aan het veld {0}.", x]); options.ModelBindingMessageProvider.SetAttemptedValueIsInvalidAccessor( (x, y) => L["De waarde {0} is niet geldig voor veld {1}.", x, y]); options.ModelBindingMessageProvider.SetMissingKeyOrValueAccessor( () => L["Een waarde is verplicht."]); options.ModelBindingMessageProvider.SetUnknownValueIsInvalidAccessor( (x) => L["De opgegeven waarde is niet geldig veld {0}", x]); options.ModelBindingMessageProvider.SetValueMustNotBeNullAccessor( (x) => L["De waarde {0} is niet geldig.", x]); }).AddDataAnnotationsLocalization(); // Add data annotation (ErrorMessage) localization
2 replies