Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ChocolatePancake
Feb 25, 2007
I agree completely about tuples. Very useful for a quick throwaway type, but if you'll be needing them any more than in the next couple of lines, make a proper type for it.

Adbot
ADBOT LOVES YOU

ChocolatePancake
Feb 25, 2007
I can see the value in returning multiple values from local functions, but I haven't personally run into that use case myself.
It's not so much that I avoid the feature, it's that creating an encapsulating type for all the return values is generally simple and more readable.

ChocolatePancake
Feb 25, 2007
Huh, I've always just returned an IActionResult and never really thought about it before.

ChocolatePancake
Feb 25, 2007
I've heard good things about NSubstitute and FakeItEasy, but haven't had a chance to test myself yet.
For what it's worth, it looks like the change got rolled back for now due to an incompatibility with MacOS.

ChocolatePancake
Feb 25, 2007
I've always materialized my join tables, but if this is the only use case you have for directly accessing/modifying that table, then I would just write the SQL query directly. Especially as it seems like a pretty simple one.

ChocolatePancake
Feb 25, 2007

Heroic Yoshimitsu posted:

This is probably a dumb question… can’t find a straight answer on it… can IdentityServer4 work with .Net6?

According to the nuget page, yes.
https://www.nuget.org/packages/IdentityServer4/4.1.2#supportedframeworks-body-tab

ChocolatePancake
Feb 25, 2007
I recommend using a 30 day trial of parallels and give it a try. I tried it once and it works fine, but I much prefer still using my desktop machine.

ChocolatePancake
Feb 25, 2007
You can also configure entity framework to log all of its sql queries. https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/

ChocolatePancake
Feb 25, 2007
It does seem to be the way the world is going, with electron apps, react native, and all that good stuff. No one wants to learn how to write native apps for both iOS and Android and maintain the two code bases. Unless you have a career entirely in stuff that doesn't use the web, you should probably learn some web design.

That said though, I doubt that Maui/Blazor is 'the' future. Blazor maybe, at least for non-tech companies it is very popular, but Maui really isn't good yet, and they don't have many people working on it. Doesn't seem like a big priority for them.

ChocolatePancake
Feb 25, 2007
If your old app is Xamarin I think upgrading it to Maui is the easiest path forward for sure.
Otherwise anything else you are looking at basically a total rewrite.

ChocolatePancake
Feb 25, 2007
Yep, multi tenant is what you want. I typically set up a separate subdomain for each tenant to make it easier on myself. So for example users from A would go to a.example.com.
If you're using 1 database for all the tenants, and using entity framework, then I would recommend setting up a global query filter so that the organization data filtering is done automatically. This will go a long way to make sure A never sees data from B and vice versa.

ChocolatePancake
Feb 25, 2007
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.

ChocolatePancake
Feb 25, 2007
I've not used Finbuckle before, but it looks intriguing. This is what I do:

code:
//put your connection strings in your appSettings.json like this:
"ConnectionStrings": {
  "TenantADataModel": "data source=<rest of connection string here>;",
  "TenantBDataModel": "data source=<rest of connection string here>;"
},

 public partial class MyDbContext : DbContext
 {
     private readonly ITenantIdentifier tenantIdentifier;
     private readonly IConfiguration configuration;

     public MyDbContext(IConfiguration configuration, ITenantIdentifier tenantIdentifier)
     {
         this.configuration = configuration;
         this.tenantIdentifier = tenantIdentifier;
     }

     protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
     {
         var connectionString = configuration
             .GetConnectionString(tenantIdentifier.GetCurrentTenantId() + "DataModel"); 
         optionsBuilder.UseSqlServer(connectionString);
     }	 
}

in Startup.cs:
 
services.AddSingleton<ITenantIdentifier, MyTenantIdentifier>();
services.AddDbContext<MyDbContext>();
From there you just inject your MyDbContext wherever you need it. Each request will get its own connection string based on the tenant ID.
This is with SqlServer, but should work the same with Postgres.

Hope that helps!

Adbot
ADBOT LOVES YOU

ChocolatePancake
Feb 25, 2007
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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply