using System; using System.Collections.Generic; using System.Linq; using DB.Entity; using NewLife.Caching; namespace DB.Service { public class PointService { public List GetList() { using (var dbContext = DbFactory.GetContext) { return dbContext.Query().ToList(); } } public string GetAddressName(string address) { using (var dbContext = DbFactory.GetContext) { var entity= dbContext.Query() .Where(x => x.PointAddress == address) .Select(x => x.PointName).FirstOrDefault(); return string.IsNullOrEmpty(entity) ? "" : entity; } } public Dictionary GetValueName() { using (var dbContext = DbFactory.GetContext) { var entity = dbContext.Query() .Select(x=>new Point() { PointAddress = x.PointAddress, PointName = x.PointName }) .ToList(); Dictionary dic = entity.ToDictionary(x => x.PointAddress, x => x.PointName); return dic; } } } }