C
C#2y ago
Johnny

Linq Where JsonSerialization not working

Hey, is there a way to get the following running:
dbSet.Set<Table>().Where(x => JsonSerializer.Deserialize<Object>(x.Value).Number1 == localGivenNumber).ToList();
dbSet.Set<Table>().Where(x => JsonSerializer.Deserialize<Object>(x.Value).Number1 == localGivenNumber).ToList();
I am getting the error an expression tree cannot contain a call or invocation that uses optional arguments
3 Replies
Mayor McCheese
What does your table entity look like?
Becquerel
Becquerel2y ago
which part of that can take optional arguments? the json .Deserialize? in any case you just need to explicitly put in the default arguments oh -- or dbSet.Set() maybe the inability to handle optional arguments is just a failing of expression trees, nothing database related
Angius
Angius2y ago
The database can't do JSON deserialization, so of course this won't work. Either a) use a database that supports JSONB b) do the filtering on the client c) save this one particular value in its own column a) would be preferable, then c) b) is a last resort
Want results from more Discord servers?
Add your server
More Posts
Microsoft's DI Hierarchically controlled lifetime manager? [Answered]With Microsoft's DI, what's the equivalent of hierarchically controlled lifetime manager? The situatDisable bootstrap multiselect options after selectingHi. I have a bootstrap `<select multiple/>`. When one is selected, I want to disable all other selecReading ConfigurationSay I have a class like this: ```cs public StepGenerator(MigrationSteps migration) { XAML Binding error, cannot find sourceHello, I do get a binding error when trying to bind a string from codebehind as content of a ComboBI want on a click of a button in form1 to change a thing in 2nd form, but can't manage [Answered]So i have 4 forms - Main menu - then 3 subForms referenced to that. In form1 i want to click button Unmanaged struct backed INPC ViewModel, only raising PropertyChanged when backing field(s) changedSo, suppose we have a large unmanaged struct that we obtain from external source, suppose from a netTrying to fade In and out ObjectI've been stuck for awhile now, Been trying to figure out how to loop it and have it fade in and outMAUI Problem [Answered]I can't run the project or build it There is a picture of a lock on these offices What is the solutiInMemory testing doesn't store seeded datahttps://github.com/Nemes1sX/EmployeeMangement/blob/master/EmployeeTest/TestEmployee.cs. For example Lambda or extension method reference [Answered]If you have an extension which maps a type A to another type B and you have an enumerable of type A