如何从DataGrid字段列获取最大值 [英] How get the max value from a DataGrid field column

查看:259
本文介绍了如何从DataGrid字段列获取最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用WPF C#中的实体框架从dataGrid字段列中获取最大值

How get the max value from a dataGrid field column using Entity Framework in WPF C#

var MaxID = dataGridView1.Rows.Cast<DataGridViewRow>()
.Max(r => Convert.ToInt32(r.Cells["Id"].Value));


推荐答案

您可以这样:

var MaxID = (EqupmentdataGrid.Items.Cast< EntityName >()).Max(r => r.Id);

例如:var MaxID =(EqupmentdataGrid.Items.Cast<'Equipment>())。Max( r => r.Id);

Ex: var MaxID = (EqupmentdataGrid.Items.Cast<'Equipment>()).Max(r => r.Id);

结果:1​​0002

Result : 10002

这篇关于如何从DataGrid字段列获取最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆