我已将我的"entityframework 4"项目升级到5.我想在Include中使用lambda表达式(我的动机是suplant字符串定义)括号.
在这个momemnt我有:
context.WarrantyContract.Include("Car");
Run Code Online (Sandbox Code Playgroud)
并希望实现这一目标:
context.WarrantyContract.Include(w => w.Car);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试更换字符串时,视觉工作室无法识别我的意愿.
我会感谢任何正确的方向.
我尝试调用EF方法ToListAsync.但没有任何事情发生 - 没有例外,没有超时只是运行.
这是我的代码.
private IQueryable<Place> placeCompleteQuery;
protected IQueryable<Place> PlaceCompleteQuery
{
get
{
return this.placeCompleteQuery ?? (this.placeCompleteQuery = this.Context.Places.Include(p => p.Address).
Include(p => p.CreatedBy).
Include(p => p.Source).
Include(p => p.Type.Translations).
Include(p => p.Ratings));
}
}
public async Task<IList<Place>> GetPlacesByLocationAsync(DbGeography location, int radius)
{
List<Place> temporaryResult = PlaceCompleteQuery.Where(p => p.Location.Distance(location) <= radius).
ToList();
return await PlaceCompleteQuery.Where(p => p.Location.Distance(location) <= radius).
ToListAsync();
}
Run Code Online (Sandbox Code Playgroud)
ToList方法的第一次同步调用立即返回结果.ToListAsync的第二次异步调用仍在运行,没有结果也没有异常.
有什么建议?
我想验证证书密码。此时我有基于处理 CryptographicException 和检查异常消息的代码。但这种方法取决于英语文化信息。
public bool VerifyPassword(byte[] fileContent, string password)
{
try
{
var certificate = new X509Certificate2(fileContent, password);
}
catch (CryptographicException ex)
{
if (ex.Message.StartsWith("The specified network password is not correct."))
{
return false;
}
throw;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我一直在寻找如何验证证书密码的其他解决方案,但没有成功。
如何验证证书密码的正确方法是什么?
我很感激任何想法......