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, ITpntStoreRepository { public TpntStoreRepository(InspectionDbContext dbContext) : base(dbContext) { } public IList GetAllPntType() { return DbContext.Set().ToList(); } public Task 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 result = EntityFrameworkCoreExtensions.GetList(DbContext.Database, sql, parameters); return Task.FromResult(result.FirstOrDefault()); } } }