我有一个使用本地SQLite数据库的.NET C#应用程序。我可以读取数据库但是如果我通过外部工具在数据库中手动更改值,我就不会读回C#代码的更改。如果我重新启动应用程序,我可以回读更改
修改
初始化;这里主要是.NET魔法
var services = new ServiceCollection();
services.AddLogging();
services.AddOptions();
services.AddDbContext<ServicesDbContext>(options =>
options.UseSqlite($"Filename={fileName}", b => b.MigrationsAssembly("ReviewerServices.Data")));
services.AddTransient<INetworkUtilities, NetworkUtilities>();
用法更简单:
public async Task<IEnumerable<FtpServerGroup>> GetFtpPullListAsync(DateTime baseTime)
{
var servers = await context.FtpServerGroup
.Include(r => r.FtpServers)
.Include(r => r.Instruments)
.Where(w => !w.Disabled)
.ToListAsync();
servers = servers.FindAll(w => baseTime - w.FtpLastPullTime >= w.FtpPullInterval);
return servers.AsEnumerable();
}