|
NihilCredo posted:i also think this is usually the cleanest option. no query filters, just a separate connection string per tenant. another thing to be wary of with one-db-per-tenant (or indeed anything that varies the db connection string per tenant) is that ef core support is sketchy, iirc. you'll need to figure that bit out on your own obviously not a concern if you're not using ef
|
# ? May 1, 2024 00:31 |
|
|
# ? May 15, 2024 21:26 |
|
If you inject your ITenantProvider with your OnConfiguring method for entity framework, you can use a scoped database service no problem. I have used this approach several times, and it works well. I can probably get you some sample code tomorrow if you like.
|
# ? May 1, 2024 01:12 |
|
ChocolatePancake posted:If you inject your ITenantProvider with your OnConfiguring method for entity framework, you can use a scoped database service no problem. I have used this approach several times, and it works well. I can probably get you some sample code tomorrow if you like. This would be appreciated! I've also been looking at Finbuckle Multitenant tonight which seems to be a potential solution as well.
|
# ? May 1, 2024 02:13 |
|
I've not used Finbuckle before, but it looks intriguing. This is what I do:code:
This is with SqlServer, but should work the same with Postgres. Hope that helps!
|
# ? May 1, 2024 02:36 |
|
It'd be different for everyone, but what criteria is commonly used to set the TenantID in MyTenantIdentifier to "TenantA" or "TenantB" in an ASP.NET Core project (the currently logged in User? the subdomain?), and where is a reasonable place to store that information?
|
# ? May 1, 2024 04:17 |
|
We like to use subdomains, storing the mapping in a config file, makes it easier for us, but there's lots of ways to skin that cat.
|
# ? May 1, 2024 04:22 |
|
You don't even need to bury it in the DbContext OnConfiguring like that, you can do it right in your application's startup. The AddDbContext extension method for IServiceCollection has an overload to provide a function that takes IServiceProvider as one of its arguments, so you can get your tenant-providing service there and keep all your configuration during service registration where it belongs.ChocolatePancake posted:We like to use subdomains, storing the mapping in a config file, makes it easier for us, but there's lots of ways to skin that cat. We do that for our IDP (mapping to tenant by hostname); then for all our application services we map based off the issuer of the passed OAuth access token. But there are still some things that are difficult to make per-tenant; so we structure our web applications to have the initial WebApplication host built, and all that host does is look at the supplied bearer token to identify the issuer, then passes the request off to a separate tenant-specific host instance (one per tenant -- created on demand when the first request for a particular tenant hits the process), which then handles it exactly like it would if it were a single tenant application because it basically *is* just running lots of separate single tenant applications all in one process. You also don't get boned if you ever need to use a library that assumes a single tenant application; and you never ever accidentally do things like mix up memory caches cross-tenant or any of the other pitfalls you might fall for if you're not hypervigilant about making sure you never accidentally assume a single tenant. biznatchio fucked around with this message at 04:37 on May 1, 2024 |
# ? May 1, 2024 04:34 |
|
epswing posted:It'd be different for everyone, but what criteria is commonly used to set the TenantID in MyTenantIdentifier to "TenantA" or "TenantB" in an ASP.NET Core project (the currently logged in User? the subdomain?), and where is a reasonable place to store that information? Our IDP just adds the tenant ID to the user's claims.
|
# ? May 1, 2024 20:51 |
|
susan b buffering posted:Our IDP just adds the tenant ID to the user's claims. I really like this method.
|
# ? May 1, 2024 23:31 |
|
I have a very newbish question, since I'm only a hobby developer and even then, I hadn't started Visual Studio for like 2 years before today so I'm a bit rusty. I'm throwing together a very simple and quick Blazor web app to centralize all the calculators and converters I need for sports (miles to km, pace to speed, pace + time to distance, etc). I'm stuck on the One-rep Max calculator trying to implement a bafflingly simple formula (Epley's), which is 1RM = Weight(1+r/30), assuming r > 1. Weight is the weight you're doing the assessment at, rep is the amount of reps you could do before failure, and this comes out as a higher number because your 1RM is supposed to be heavier than your, say, 5RM. For instance a 5RM at 50kg should come out as 56.3kg (according to another calculator). Sorry for the long intro, I wanted to give context. Anyway, my code is dumb and so far is: code:
Is there something very basic and dumb I'm missing here?
|
# ? May 5, 2024 14:28 |
|
You're doing integer division. Cast the int to a double first
|
# ? May 5, 2024 14:35 |
|
Ooh, because I'm using two different types the compiler needs to know which one I actually need, and since I don't specify it by casting the type then it just uses the simpler of the two?
|
# ? May 5, 2024 14:38 |
|
Furism posted:Ooh, because I'm using two different types the compiler needs to know which one I actually need, and since I don't specify it by casting the type then it just uses the simpler of the two? Pretty much. Since RepAmount is an int and .NET interprets the literal 30 as an int, it doesn't change it to a double until it needs to. You can either cast RepAmount as part of the equation, or change the 30 to 30.0 and that should do it. E: or just change the declared type of RepAmount to double if you want
|
# ? May 5, 2024 14:41 |
|
Thanks for the clarification, appreciate it. Working fine now!
|
# ? May 5, 2024 14:46 |
|
Is there a forum or a Discord for SixLabors ImageSharp, or any way to get help with that library? I've been using ImageSharp to load up .png files, clone -> rotate -> resize them, and save as webp files. And every once in a while, the files are exported as animated webps (which are indistinguishable to every browser but which Discord can't parse). Why? No idea. All the png files are sourced from various sources (sometimes a PNG or JPG, sometimes a WEBP, often a screen grab), and then cropped in Affinity and exported as png files before running through my C# code. So 1 in 30 or 40 images are coming out as animated webp, even though they always start as png files. Any insight?
|
# ? May 8, 2024 19:02 |
|
CitizenKeen posted:Is there a forum or a Discord for SixLabors ImageSharp, or any way to get help with that library? Is it consistent? If you re-process the same file that resulted in an animated webp, does it still/always result in an animated webp file?
|
# ? May 8, 2024 19:16 |
|
You described the symptom "does not work in Discord" but how did you get from that to "it is an animated webp"?
|
# ? May 8, 2024 19:42 |
|
From having a look at the source code, maybe some of the PNGs you have are actually APNGs? Those would be able to contain multiple frames while still being completely backwards compatible with regular PNG (displayed as the first frame only by programs that don't understand APNG). ImageSharp understands APNGs and would dutifully convert them into animated WEBPs. If I understand the ImageSharp API correctly, I guess you could try loading all images with the DecoderOptions configured with MaxFrames = 1, which would get rid of any animated file content and convert everything to a normal WEBP.
|
# ? May 8, 2024 20:51 |
|
epswing posted:Is it consistent? If you re-process the same file that resulted in an animated webp, does it still/always result in an animated webp file? Yes, the same files will result in the same problem. EssOEss posted:You described the symptom "does not work in Discord" but how did you get from that to "it is an animated webp"? I posted two webp files - one that previews in Discord, one that does not - in the D Sharp Plus Discord (the Discord .NET bot library I'm using) and it was noted the working one was a webp, the not-working one is an animated webp, and that Discord does not render animated webp files. SirViver posted:From having a look at the source code, maybe some of the PNGs you have are actually APNGs? Those would be able to contain multiple frames while still being completely backwards compatible with regular PNG (displayed as the first frame only by programs that don't understand APNG). ImageSharp understands APNGs and would dutifully convert them into animated WEBPs. I've never heard of an APNG file. That's a strong contender for the culprit: If i start with an animated WEBP, open and edit in Affinity, then export, and it exports as an APNG, then run my ImageSharp code against it, I could see that being the culprit. I had no idea animated PNGs were a thing - this gives me an avenue for an investigation. Thank you!
|
# ? May 8, 2024 21:12 |
|
APNG is a non-standard extension, hence why it's kinda rare but some people still use it because it's less stupid than webm/animated webp. The Correct(TM) way of doing it would be to see if there's more than one frame in the png and if so convert to webm instead but that's, y'know, a whole lot of extra effort.
|
# ? May 8, 2024 22:51 |
|
|
# ? May 15, 2024 21:26 |
|
Kyte posted:APNG is a non-standard extension, hence why it's kinda rare but some people still use it because it's less stupid than webm/animated webp. Not to clutter the .NET thread but I don't want the extra frames (I suspect someone upstream is making them animated by accident - they're static images), so I'm just flattening them when I convert from WEBP to PNG. Seems to solve the problem just fine.
|
# ? May 8, 2024 23:06 |