零框架多租户设计方案
This commit is contained in:
1 parent
b7caaa2d0c
commit
b4a704526d
42 files changed
+1002
-1
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MultiTenancySample.FieldIsolationService.Entities;
|
||||
using MultiTenancySample.FieldIsolationService.EntityFrameworks;
|
||||
|
||||
namespace MultiTenancySample.FieldIsolationService.Controllers
|
||||
{
|
||||
[Route("api/{tenant}/[controller]")]
|
||||
[ApiController]
|
||||
public class ProductsController(IDbContextFactory<FieldIsolationServiceDbContext> dbContextFactory) : ControllerBase
|
||||
{
|
||||
private readonly FieldIsolationServiceDbContext _dbContext = dbContextFactory.CreateDbContext();
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetProducts(string? keyword)
|
||||
{
|
||||
IQueryable<Product> products = _dbContext.Set<Product>();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
products = products.Where(p => p.Name.Contains(keyword));
|
||||
}
|
||||
|
||||
return Ok(products);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user