我在从NHibernate返回的IQueryable上使用LINQ,我需要在几个字段中选择具有最大值的行.
我简化了我坚持的一点点.我需要从表中选择一行,并在一个字段中使用最大值.
var table = new Table { new Row(id: 1, status: 10), new Row(id: 2, status: 20) }
from u in table
group u by 1 into g
where u.Status == g.Max(u => u.Status)
select u
Run Code Online (Sandbox Code Playgroud)
这是不正确的,但我无法找到正确的表格.
顺便说一下,我实际上想要实现的是这样的:
var clientAddress = this.repository.GetAll()
.GroupBy(a => a)
.SelectMany(
g =>
g.Where(
a =>
a.Reference == clientReference &&
a.Status == ClientStatus.Live &&
a.AddressReference == g.Max(x => x.AddressReference) &&
a.StartDate == g.Max(x => x.StartDate)))
.SingleOrDefault();
Run Code Online (Sandbox Code Playgroud)
我从上面的lambda开始,但我一直在使用LINQPad来尝试找出选择Max()的语法.
UPDATE
删除GroupBy是关键.
var all = this.repository.GetAll();
var …Run Code Online (Sandbox Code Playgroud) 我在我的开发机器上通过TeamCity运行的构建中收到以下错误:
[ResolveServiceConfiguration] WATMessage
[16:02:05][WATMessage] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Windows Azure Tools\1.7\Microsoft.WindowsAzure.targets(354, 5): No default service configuration "ServiceConfiguration.cscfg" could be found in the project.
[16:02:05][Xxx.Azure.Production\Xxx.Azure.Production.ccproj] Project Xxx.Azure.Production\Xxx.Azure.Production.ccproj failed.
Run Code Online (Sandbox Code Playgroud)
在VS.NET中构建同样的解决方案.
我认为我需要做的是TargetProfile为每个Azure项目设置(有多个抱怨)来覆盖默认值,Cloud但我找不到在哪里做这个.
那么如何为Azure项目设置目标配置文件?
此代码使用Microsoft Web Api Http堆栈和jQuery.
如何获取由jQuery的deferred.fail()显示的由HttpError参数创建的自定义错误消息给CreateErrorResponse ()?
在ApiController中为测试目的创建错误响应的示例:
public HttpResponseMessage Post(Region region)
{
var error = new HttpError("Failure to lunch.");
return this.Request.CreateErrorResponse(
HttpStatusCode.InternalServerError,
error);
}
Run Code Online (Sandbox Code Playgroud)
这是一个减少客户端,试图找到要显示的错误消息,"未能午餐.".
$.ajax({
type: 'POST',
url: 'api/region',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(region)
})
.fail(function (jqXhr, textStatus, errorThrown) {
alert(textStatus + ": " + errorThrown + ": " + jqXhr.responseText);
});
Run Code Online (Sandbox Code Playgroud)
将显示的是:
"错误:内部服务器错误:{full stack here}"
我想要的是:
"没有吃午饭."
我一直在使用git subtree split将一个巨大的存储库(从另一个VCS导入Git)分成更小的存储库.
$ git subtree split -P ./path/to/folder/ -b folder-only
Run Code Online (Sandbox Code Playgroud)
这已经工作了,我已经将几个文件夹移动到新的存储库中,但是在运行所有可用的提交之后,他们的兄弟姐妹的尝试没有创建分支.
最后的信息是
"没有找到新的修订"
我不知道这是否重要,但运行时--debug会发出如下消息
处理提交:ca9d25944cf34bbe7aa356248a166ac1fb813f2a
parent:fc0e5a621ab871b8a11071eec321f4b40b8dcce0
newparents:
tree is:
为什么git subtree split失败了,我能做些什么呢?
当从 ASP.NET Web API 使用 RazorEngine 时@Url.Content(),我如何开始工作_Layout.cshtml?
RazorEngine (v.3.7.2) 只处理 Razor 语法,而不处理额外的辅助方法,如@Html或@Url。这些可以通过TemplateBase<>在配置中扩展和设置来添加。
一些老问题中有代码示例:#26 , #29;在MvcTemplateBase.cs 中未发布的、不完整的一段代码中;并在扩展模板语法的文档中。
我的问题是我使用的 ASP.NET Web API (v.1) 没有HttpContext.Current(也不应该)。我想提供一个,UrlHelper因为我想使用它的Content()方法,但它需要用不可用的 实例化HttpRequestMessage。
也许没有办法为我的编译布局获取 @Url 辅助方法。也许我需要一些其他方式从虚拟路径获取绝对路径。看来我仍然需要某种方式来检查请求。
c# ×2
.net ×1
azure ×1
git ×1
git-subtree ×1
httpresponse ×1
jquery ×1
jqxhr ×1
linq ×1
razorengine ×1
teamcity-7.0 ×1