You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/DB/Service/PointService.cs

52 lines
1.4 KiB
C#

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