Enumerable.Max<TSource> Method (IEnumerable<TSource>, Func<TSource, Double>)

宠物年龄加名字长度的最大值
            class Pet
            {
                public string Name { get; set; }
                public int Age { get; set; }
            }

            public static void MaxEx4()
            {
                Pet[] pets = { new Pet { Name="Barley", Age=8 },
                               new Pet { Name="Boots", Age=4 },
                               new Pet { Name="Whiskers", Age=1 } };

                int max = pets.Max(pet => pet.Age + pet.Name.Length);

                Console.WriteLine(
                    "The maximum pet age plus name length is {0}.",
                    max);
            }

 

此异常最初是在此调用堆栈中引发的: MySqlConnector.Core.ServerSession.StartQuerying(MySqlConnector.Core.ICancellableCommand) - 位于 ServerSession.cs MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(MySqlConnector.Core.CommandListPosition, MySqlConnector.Core.ICommandPayloadCreator, System.Data.CommandBehavior, System.Diagnostics.Activity, MySqlConnector.Protocol.Serialization.IOBehavior, System.Threading.CancellationToken) - 位于 CommandExecutor.cs MySqlConnector.MySqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior, MySqlConnector.Protocol.Serialization.IOBehavior, System.Threading.CancellationToken) - 位于 MySqlCommand.cs Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(Microsoft.EntityFrameworkCore.Storage.RelationalCommandParameterObject) Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable<T>.Enumerator.InitializeReader(Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable<T>.Enumerator) Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute<TState, TResult>(TState, System.Func<Microsoft.EntityFrameworkCore.DbContext, TState, TResult>, System.Func<Microsoft.EntityFrameworkCore.DbContext, TState, Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>>) Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable<T>.Enumerator.MoveNext() System.Linq.Enumerable.TryGetSingle<TSource>(System.Collections.Generic.IEnumerable<TSource>, out bool) HX.BacteriumExamSys.Infrastructure.Utils.DataProvider.AESCriteriaInfoProvider.GetCriterion(long) - 位于 AESCriteriaInfoProvider.cs
08-22
System.InvalidCastException HResult=0x80004002 Message=指定的转换无效。 Source=System.Data.DataSetExtensions StackTrace: 在 System.Data.DataRowExtensions.UnboxT`1.ValueField(Object value) 在 System.Data.DataRowExtensions.Field[T](DataRow row, String columnName) 在 HYAppFrame.WarehouseManage.FormWareHouseqty.<>c.<btn_query_Click>b__1_2(DataRow r) 在 C:\PTcode\Ex-MES-app\源文件\P8\P8Client_PRD\HYAppFrame\WarehouseManage\FormWareHouseqty.cs 中: 第 36 行 在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 在 System.Linq.Enumerable.Sum(IEnumerable`1 source) 在 System.Linq.Enumerable.Sum[TSource](IEnumerable`1 source, Func`2 selector) 在 HYAppFrame.WarehouseManage.FormWareHouseqty.<>c.<btn_query_Click>b__1_1(IGrouping`2 grp) 在 C:\PTcode\Ex-MES-app\源文件\P8\P8Client_PRD\HYAppFrame\WarehouseManage\FormWareHouseqty.cs 中: 第 33 行 在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 在 HYAppFrame.WarehouseManage.FormWareHouseqty.btn_query_Click(Object sender, EventArgs e) 在 C:\PTcode\Ex-MES-app\源文件\P8\P8Client_PRD\HYAppFrame\WarehouseManage\FormWareHouseqty.cs 中: 第 40 行 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ButtonBase.WndProc(Message& m) 在 System.Windows.Forms.Button.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 在 System.Windows.Forms.Application.Run(Form mainForm) 在 HYAppFrame.Program.Main() 在 C:\PTcode\Ex-MES-app\源文件\P8\P8Client_PRD\HYAppFrame\Program.cs 中: 第 22 行
最新发布
12-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值