'How to get ShopId in a multi vendor ASP.NET Core 6 application?
I'm using Entity Framework.
public class Store : IEntity<Guid>
{
public Guid Id { get; set; }
public string Handle { get; set; } //sub-domain
public string StoreName { get; set; }
public string? StoreUrl { get; set; } //main url
}
This is the StoreDbContext
public class StoreDbContext : DbContext, IStoreDbContext
{
private readonly string _connectionString;
private readonly string _assemblyName;
public StoreDbContext(string connectionString, string assemblyName)
{
_connectionString = connectionString;
_assemblyName = assemblyName;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionBuilder)
{
if (!optionBuilder.IsConfigured)
{
optionBuilder.UseSqlServer(_connectionString, m => m.MigrationsAssembly(_assemblyName));
}
base.OnConfiguring(optionBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder) {
//many to many(prodcut to category)
modelBuilder.Entity<ProductCategory>().HasKey(c => new { c.ProductId, c.CategoryId });
public DbSet<STORE> Stores { get; set; }
}
I have created a StoreInfoService. Here, I want to get StoreId via this method GetStoreId(). What should be my process?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
