Up
Explore posts from serversPPrisma
•Created by Up on 6/27/2024 in #help-and-questions
N+1 problem with multiple filter conditions
I have a table that maps access to "file groups" per user, for a range of time periods. each group having a different expiry date for each user.
Now I want to retrieve all files that a user has ever had access to.
for that, the naive approach would be something like
1. query the file access table: select file_group and exp_date, where user = $currentUser, order by exp_date descending, distinct per file_group, limit 1.
2. for each result pair -> query the files table: select *, where file_group = $pair.group AND created_at <= pair.exp_date
Now I know the prisma DSL has ways to mitigate this for "simple" cases where there is only 1 condition to join on, but I am not sure how I would do it with both of these conditions, as it would need to reference the result of the previous query somehow.
So I guess my question is, is there a way to do this in a single prisma client call, or am I better off manually parsing the result of the first request, collecting all the file group IDs and dates and then passing these on to the second request?
5 replies
✅ EF Core Relations don't seem to work properly
I'm trying to model a fairly complex set of relations in EntityFramework core / ASP.NET, but am failing to create a new entry as the system insists it already exists; yet the corresponding table in the DB is empty
43 replies
ASP.NET MVC Legacy Route Hell
So I have a very old API that was originally written in MVC.
this api manages projects where each project has an ID + user-friendly slug, and then has a bunch of files that each have file name + file ID.
now I have an MVC route mapping that I will need to know how it resolves, so I can then extract those properties from the URL back to my own application.
4 replies
C++ Interop - writing a shim to use an existing c++ library [Answered]
So I'm currently trying to make a shim for a C++ library that I can then call from C#.
The original library uses CMake, not MSBuild, so I've set up Cmake, let it generate the .vcxproj files, made a 2nd C++ project for my shim classes and made it depend on the generated projects.
Then I've added that + the generated projects into my C# msbuild solution.
Now I am trying to call a hello world function that I made in my shim library form C#, but that immediately fails with no indicator as to what went wrong. all I get is
System.Runtime.InteropServices.SEHException: 'External component has thrown an exception.'
.
How I declared it on the C++ side:
How I declared it on the C# side:
any help appreciated!101 replies