Utsuhoagie
Utsuhoagie
Explore posts from servers
CC#
Created by Utsuhoagie on 8/10/2024 in #help
EF Core with TPC hierarchy: InvalidCastException despite no casting
But still, I want to figure out what causes the issue, I really don't understand why it's trying to cast objects that aren't related, and I'm not casting anything My best guess is that many entities have the same int IDs because they used to be separate and EF Core itself is trying to cast them randomly to other types
12 replies
CC#
Created by Utsuhoagie on 8/10/2024 in #help
EF Core with TPC hierarchy: InvalidCastException despite no casting
Perhaps you're right. It's really just a small project I'm practicing, nothing serious. At most I would expect about 8 different entity types, but currently it's just about 4
12 replies
CC#
Created by Utsuhoagie on 8/10/2024 in #help
EF Core with TPC hierarchy: InvalidCastException despite no casting
I could simply not use any inheritance and just manually have nullable navigations for each entity type instead (there's just gonna be like 8 max anyway), but I wanted to try doing something I've never done before
12 replies
CC#
Created by Utsuhoagie on 8/10/2024 in #help
EF Core with TPC hierarchy: InvalidCastException despite no casting
I mean, that's exactly what I did before. When I started working on this feature, I realized TierListItem could be related to basically any other entity in the app, and so I made all of them inherit from BaseEntity (or audited)
12 replies
CC#
Created by Utsuhoagie on 8/10/2024 in #help
EF Core with TPC hierarchy: InvalidCastException despite no casting
What I planned is to allow the user to navigate to the "source" of a TierListItem by clicking on it, which would require the type + PK (in this case just an ID) Also, I currently have 1 but potentially a few more methods on BaseEntity which returns a formatted label string depending on the derived class, so I'm thinking to keep this hierarchy
12 replies
CC#
Created by Utsuhoagie on 8/10/2024 in #help
EF Core with TPC hierarchy: InvalidCastException despite no casting
TierListItem is simply any kind of item that can be made into tier lists. For example you could make tier lists for songs, circles (music groups), remixes, games, characters,... So I wanted TierListItem to have a relation to a BaseAuditedEntity, because most entities can be a tier list item
12 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
This is on React Native on a physical phone though (specifically it's an Expo app, running on Expo Go on an Android). The only "devtools" I have are in the screenshot which is pretty primitive (there used to be a debugger app for older versions but I can't get it to run on my current version)
18 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
SOLVED (Kind of) I was dumb, and maybe the Network inspector lied to me. What I was trying to append() to was actually a Date object, not an ISO timestamp string. I just used the wrong explicit type in TypeScript (fix BirthDate?: string to BirthDate?: Date, because a date picker component was changing BirthDate into a Date), so it was trying to append a Date instead, and while the Network inspector still shows an ISO string (like the screenshot above), my server can't bind the property at all. Fixing the types worked, even though the Network inspector still shows the same data being sent.
18 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
18 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
How do I check that? Closest I could try is this Network inspector in Expo Go:
18 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
It looks pretty normal to me, I tried checking the Network inspector in Expo Go and it does contain an actual timestamp for BirthDate
18 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
This?
18 replies
CC#
Created by Utsuhoagie on 4/27/2023 in #help
✅ Nullable DateTimeOffset field in a [FromForm] model is always null
// NationalId, Address, Phone, BirthDate are all strings. BirthDate is possibly undefined.
const formData = new FormData();
formData.append('NationalId', NationalId);
formData.append('Address', Address);
formData.append('Phone', Phone);
if (BirthDate) {
formData.append('BirthDate', BirthDate);
}
if (Image) {
formData.append('Image', Image);
}

const res = await axios.put(
`Employees/UpdateSelf/${NationalId}`,
formData,
{ headers: { 'Content-Type': 'multipart/form-data' } }
);
// NationalId, Address, Phone, BirthDate are all strings. BirthDate is possibly undefined.
const formData = new FormData();
formData.append('NationalId', NationalId);
formData.append('Address', Address);
formData.append('Phone', Phone);
if (BirthDate) {
formData.append('BirthDate', BirthDate);
}
if (Image) {
formData.append('Image', Image);
}

const res = await axios.put(
`Employees/UpdateSelf/${NationalId}`,
formData,
{ headers: { 'Content-Type': 'multipart/form-data' } }
);
18 replies
CC#
Created by Utsuhoagie on 4/1/2023 in #help
❔ Why is my ASP.NET Core Web API not responding at all to a `multipart/form-data` request?
Now that I think about it, since it does work in Postman with a similar request (uploading a file from my PC instead of getting the file from a URI on the Android itself), it's probably a problem on the mobile app's end and not my server, so here's probably not where to ask it
5 replies
CC#
Created by Utsuhoagie on 4/1/2023 in #help
❔ Why is my ASP.NET Core Web API not responding at all to a `multipart/form-data` request?
Still doesn't work. The weird thing is that it does work in Postman, but not in my Expo Go (React Native on physical Android) app
5 replies
CC#
Created by Utsuhoagie on 10/25/2022 in #help
LINQ expression could not be translated after converting object
Wow, that is literally my issue. Can't get better help than that! Thanks to both of you for the help
15 replies
CC#
Created by Utsuhoagie on 10/25/2022 in #help
LINQ expression could not be translated after converting object
Thanks! I haven't seen these keywords so far, I'll need to read up on this
15 replies
CC#
Created by Utsuhoagie on 10/25/2022 in #help
LINQ expression could not be translated after converting object
Okay so I think what I'm being confused about is: how is this line IQueryable<BugDTO> bugDTOs = bugs.Select(bug => ConvertToDTO(bug)) still working, if I just don't query .Where on bugDTOs afterwards (added some types for clarity) Is it because the .Select returns a different type, only after it has queried the DB, so the BugDTO type not existing in the DB not cause a problem? And if I call another query, which is now on an IQueryable<BugDTO> rather than the usual IQueryable<Bug>, and since BugDTO does not exist in the DB, it only causes an error now?
15 replies
CC#
Created by Utsuhoagie on 10/25/2022 in #help
LINQ expression could not be translated after converting object
(thinking rn, I'm still confused, late replies)
15 replies
CC#
Created by Utsuhoagie on 10/25/2022 in #help
LINQ expression could not be translated after converting object
Thanks! This worked, though I'm not too concerned about performance right now. What I'm wondering is how my initial _context.Bugs.Select(bug => ConvertToDTO(bug)) still works, if isFixed is null and the .Where query isn't run, which is why I initially thought the problem was with my .Where query and not my .Select
15 replies