This commit is contained in:
2021-02-27 20:42:47 +00:00
parent d92774ebdf
commit 8097175314
4 changed files with 66 additions and 4 deletions

View File

@@ -89,6 +89,8 @@ namespace AyaNova.Models
public virtual DbSet<DashboardView> DashboardView { get; set; }
public virtual DbSet<ServiceBank> ServiceBank { get; set; }
public virtual DbSet<ViewRestockRequired> ViewRestockRequired { get; set; }
//Note: had to add this constructor to work with the code in startup.cs that gets the connection string from the appsettings.json file
@@ -111,7 +113,12 @@ namespace AyaNova.Models
foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
// Replace table names
entity.SetTableName("a" + entity.GetTableName().ToLowerInvariant());
var entityName = entity.GetTableName().ToLowerInvariant();
if (!entityName.StartsWith("view"))
entity.SetTableName("a" + entityName);
else
entity.SetTableName(entityName);
// Replace column names
foreach (var property in entity.GetProperties())

View File

@@ -0,0 +1,34 @@
namespace AyaNova.Models
{
//Note this is how to define a View backed model with no key (id)
[Microsoft.EntityFrameworkCore.Keyless]
public class ViewRestockRequired
{
public long PartId { get; set; }
public long PartWarehouseId { get; set; }
public string PartNumber { get; set; }
public string DisplayWarehouse { get; set; }
public long ManufacturerId { get; set; }
public string DisplayManufacturer { get; set; }
public long WholesalerId { get; set; }
public string DisplayWholesaler { get; set; }
public long AlternativeWholesalerId { get; set; }
public string DisplayAlternativeWholesaler { get; set; }
public decimal MinimumQuantity { get; set; }
public decimal Balance { get; set; }
public decimal OnOrderQuantity { get; set; }
public decimal RequiredQuantity { get; set; }
}//eoc
}//eons
/*
SELECT apart.id AS partid, apartwarehouse.id AS partwarehouseid, apart.partnumber, apartwarehouse.name AS displaywarehouse, "
+ "amanufacturer.id AS manufacturerid, amanufacturer.name AS displaymanufacturer, awholesaler.id AS wholesalerid, awholesaler.name AS displaywholesaler, "
+ "aalternativewholesaler.id AS alternativewholesalerid, aalternativewholesaler.name AS displayalternativewholesaler,"
+ "apartstocklevel.minimumquantity, vpartinventorynow.balance, COALESCE(vpartsonorderuncommitted.quantityonorder,0) AS onorderquantity, "
+ "apartstocklevel.minimumquantity - (COALESCE(vpartinventorynow.balance, 0) + COALESCE(vpartsonorderuncommitted.quantityonorder, 0)) AS requiredquantity "
*/