小编Dha*_*rma的帖子

如何在实体框架中对一列进行求和

我正在尝试总结一个列并明智地获取详细信息

我的表数据是

id   membername     cost
1   a               100
2   aa              100
3   a               100
4   aa                0
5   b               100
Run Code Online (Sandbox Code Playgroud)

在实体框架中,我尝试对成本列求和并得到这样的结果

membername             totalcost
a                      200
aa                     100
b                      100
Run Code Online (Sandbox Code Playgroud)

然后我这样做

var result = from o in db.pruchasemasters.Where(d => d.memberid == d.membertable.id && d.entrydate >= thisMonthStart && d.entrydate <= thisMonthEnd)
                     group o by new { o.membertable.members } into purchasegroup
                     select new
                     {
                         membername = purchasegroup.Key,
                         total = purchasegroup.Sum(s => s.price)
                     };
Run Code Online (Sandbox Code Playgroud)

如何阅读结果并且我的代码是否合适?

c# entity-framework-4

9
推荐指数
1
解决办法
4万
查看次数

ASP.NET Core 2.2 中面临问题“提供的 URI 方案‘https’无效;需要‘http’。\r\n参数名称:via”

在 asp.net core 2.2 中使用 Galileo Flight UAPI API 时出现错误。当调用异步方法时出现一个错误

提供的 URI 方案“https”无效;预期为“http”。参数名称:via

我已经根据 .net core 的要求更新了 lib 并更改了 BasicHttpBinding

我根据谷歌和 Stackoverflow 搜索更改了代理

private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
    if ((endpointConfiguration == EndpointConfiguration.AirLowFareSearchPort))
    {
        System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
        result.MaxBufferSize = int.MaxValue;
        result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
        result.MaxReceivedMessageSize = int.MaxValue;
        result.AllowCookies = true;
        result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
        result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Ntlm;
        result.TransferMode = System.ServiceModel.TransferMode.Buffered;
        return result;
    }
    throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
Run Code Online (Sandbox Code Playgroud)
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-webapi asp.net-core-2.2

3
推荐指数
1
解决办法
7581
查看次数