所以我有这个:
IEnumerable<IGrouping<UInt64, MyObject>> groupedObjects = myObjectsResults.GroupBy(x => x.Id);
问题是,如何将此结果转换为IEnumerable<List<MyObject>>
?
这是我可以接受的:
IEnumerable<List<MyObject>> groupedObjects = (myObjectsResults.GroupBy(x => x.Id).SelectMany(group => group).ToList());
这显然是不正确的.有任何想法吗?
在我的项目中,我一直在使用Linq's Sum()
很多东西.它由MySQL上的NHibernate提供支持.在我的Session Factory
我已经明确要求NHibernate的处理正好是8位小数,当涉及到decimals
:
public class DecimalsConvention : IPropertyConvention
{
public void Apply(IPropertyInstance instance)
{
if (instance.Type.GetUnderlyingSystemType() == typeof(decimal))
{
instance.Scale(8);
instance.Precision(20);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我发现将.Sum()
小数点后5位的数字四舍五入:
var opasSum = opasForThisIp.Sum(x => x.Amount); // Amount is a decimal
在上面的语句中opaSum
等于2.46914,而它应该是2.46913578(直接在MySQL上计算).opasForThisIp
是类型的IQueryable<OutgoingPaymentAssembly>
.
我需要所有Linq计算来处理8个小数位decimals
.
有关如何解决此问题的任何想法?
编辑1:我发现var opasSum = Enumerable.Sum(opasForThisIp, opa => opa.Amount);
产生了正确的结果,但问题仍然存在,为什么.Sum()
要对结果进行舍入以及如何修复它?
编辑2:生成的SQL似乎有问题:
select cast(sum(outgoingpa0_.Amount) as DECIMAL(19,5)) as col_0_0_
from …
Run Code Online (Sandbox Code Playgroud) 我试图在Visual Studio 2013中的新ASP.NET MVC 5应用程序的默认主题中更改简单的CSS属性.特别是我需要更改导航菜单的背景颜色.
我通过Firebug找到了这个属性,它的新值应该是:
.navbar-inverse { background-color: #5B80A5}
Run Code Online (Sandbox Code Playgroud)
我最初尝试添加覆盖CSS行,Site.css
因为我注意到这些行BundleConfig.cs
:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
Run Code Online (Sandbox Code Playgroud)
但是导航菜单的背景颜色没有改变.
然后.navbar-inverse
我在我的解决方案中搜索并返回搜索:
Web\Content\bootstrap-theme.css(240):.navbar-inverse {
Web\Content\bootstrap-theme.css(249):.navbar-inverse .navbar-nav > .active > a {
Web\Content\bootstrap-theme.css(259):.navbar-inverse .navbar-brand,
Web\Content\bootstrap-theme.css(260):.navbar-inverse .navbar-nav > li > a {
Web\Content\bootstrap-theme.css.map(1):{"version":3,"file":"bootstrap-theme.css","sources":["less/theme.less","less/mixins/vendor-prefixes
Web\Content\bootstrap-theme.min.css(5): */.btn-default,.btn-primary,.btn-success,.btn-info,.btn-warning,.btn-danger{text-shadow:0 -1px 0 r
Web\Content\bootstrap.css(4190):.navbar-inverse {
Web\Content\bootstrap.css(4194):.navbar-inverse .navbar-brand {
Web\Content\bootstrap.css(4197):.navbar-inverse .navbar-brand:hover,
Web\Content\bootstrap.css(4198):.navbar-inverse .navbar-brand:focus {
Web\Content\bootstrap.css(4202):.navbar-inverse .navbar-text {
Web\Content\bootstrap.css(4205):.navbar-inverse .navbar-nav > li > a {
Web\Content\bootstrap.css(4208):.navbar-inverse .navbar-nav > li > a:hover,
Web\Content\bootstrap.css(4209):.navbar-inverse .navbar-nav > li > a:focus { …
Run Code Online (Sandbox Code Playgroud)