我想从@where获取数据库中的所有记录,然后更新它们.为此,我创建了一个这样的查询:
public async Task MarkAllAsActive()
{
var currentUserId = _userManager.GetCurrentUserId();
await _workOrders.Where(row => row.Status == WorkOrderStatus.Draft).ForEachAsync(row =>
{
row.Status = WorkOrderStatus.Active;
_uow.MarkAsChanged(row, currentUserId);
});
}
Run Code Online (Sandbox Code Playgroud)
但是此查询选择数据库中的所有字段并不好.为了解决这个问题我尽量选择像刚才特定字段ID,Status:
public async Task MarkAllAsActive()
{
var currentUserId = _userManager.GetCurrentUserId();
await _workOrders.Select(row=>new WorkOrder { Id=row.Id,Status=row.Status}).Where(row => row.Status == WorkOrderStatus.Draft).ForEachAsync(row =>
{
row.Status = WorkOrderStatus.Active;
_uow.MarkAsChanged(row, currentUserId);
});
}
Run Code Online (Sandbox Code Playgroud)
但它返回此错误:
无法在LINQ to Entities查询中构造实体或复杂类型"DataLayer.Context.WorkOrder".
我看过类似的帖子和同样的错误,但我的问题不同,因为我想更新.
我怎样才能做到这一点?
我使用https://cssminifier.com/缩小了一个 css 文件,但是当我想将minify结果复制到visual studio 2017它时,它不是minify,并且与之前的相同。
有很多spaces,new lines并且......
但是当我尝试使用 Visual Studio 2015 时,一切正常并且工作正常。
有什么特殊设置吗?
代码示例是:
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
z-index: 100
}
.animated.infinite {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite
}
Run Code Online (Sandbox Code Playgroud) 我正在使用最新版本的Auto Mapper 6.1.0'.我有 Poll和PolOption下面的表格:
public class Poll
{
public int Id { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public virtual ICollection<PollOption> Options { get; set; }
}
public class PollOption
{
public virtual string Title { get; set; }
public int Id { get; set; }
public int PollId { get; set; }
public virtual Poll Poll { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有两个viewModels这样的模型像: …