12345678910111213141516171819202122232425262728293031323334353637 |
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.Entities;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Repository
- {
- public class TpntStoreRepository : RepositoryBase<TPNT_Store, Guid>, ITpntStoreRepository
- {
- public TpntStoreRepository(InspectionDbContext dbContext) : base(dbContext)
- {
- }
- public IList<TPNT_Type> GetAllPntType()
- {
- return DbContext.Set<TPNT_Type>().ToList();
- }
- public Task<TpntStoreViewModel> GetStoreByCodeAsync(string code)
- {
- MySqlConnector.MySqlParameter[] parameters = new[] { new MySqlConnector.MySqlParameter("code", code) };
- string sql = @"SELECT C.*,D.C_Name AS TypeName,G.C_Code AS ProvCode,G.C_Name AS ProvName,F.C_Code AS CityCode,F.C_Name AS CityName,E.C_Code AS AreaCode,E.C_Name AS AreaName FROM TPNT_Store C
- INNER JOIN TPNT_Type D ON D.C_Code = C.C_TypeCode
- INNER JOIN TBDM_Area E on E.C_Code = C.C_AreaCode
- INNER JOIN TBDM_City F ON F.C_Code = E.C_CityCode
- INNER JOIN TBDM_Prov G ON G.C_Code = F.C_ProvCode
- WHERE C.C_Code = @code";
- IEnumerable<TpntStoreViewModel> result = EntityFrameworkCoreExtensions.GetList<TpntStoreViewModel>(DbContext.Database, sql, parameters);
- return Task.FromResult(result.FirstOrDefault());
- }
- }
- }
|