本文介绍了通过LINQ分组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要LINQ的帮助。



我有一个带有架构的SQL表如下:



| EmployeeName |金额| DatePaid |



|罗伯特加里| 1200 | 12-08-2014 |



|汤姆米歇尔| 1100 | 12-07-2014 |



|汤姆米歇尔| 500 | 07-07-2014 |



|罗伯特加里| 1200 | 05-08-2014 |



|罗伯特加里| 1200 | 28-11-2012 |



|罗伯特加里| 1200 | 12-08-2013 |





----------





我想将输出分组并在UI(Web Form html表格)上显示如下:



Robert Gary:



|金额| DatePaid |



| 1200 | 12-08-2014 |



| 1200 | 05-08-2014 |



| 1200 | 28-11-2012 |



| 1200 | 12-08-2013 |





Tom Michel



|金额| DatePaid |



| 1100 | 12-07-2014 |



| 500 | 07-07-2014 |





有没有办法通过LINQ或一些SQL语句来实现它来操作数据。

感谢任何帮助。



非常感谢!

I need a help with LINQ.

I have a SQL table with schema as follows:

| EmployeeName | Amount | DatePaid |

| Robert Gary | 1200 | 12-08-2014 |

| Tom Michel | 1100 | 12-07-2014 |

| Tom Michel | 500 | 07-07-2014 |

| Robert Gary | 1200 | 05-08-2014 |

| Robert Gary | 1200 | 28-11-2012 |

| Robert Gary | 1200 | 12-08-2013 |


----------


I want to group the output and display on the UI (Web Form html table) as follows:

Robert Gary:

| Amount | DatePaid |

| 1200 | 12-08-2014 |

| 1200 | 05-08-2014 |

| 1200 | 28-11-2012 |

| 1200 | 12-08-2013 |


Tom Michel

| Amount | DatePaid |

| 1100 | 12-07-2014 |

| 500 | 07-07-2014 |


Is there a way i can achieve it through LINQ or some SQL statement to manipulate data.
Appreciate any help.

Thank You Very Much!

推荐答案

var groupedElement = from element in Orders
                     group element by element.EmployeeName into elementGroup
                     select new {name = elementGroup.key , details= elementGroup }







订单包含所有名称,金额,DatePaid详细信息




"Order" contains all the Name, amount, DatePaid details


这篇关于通过LINQ分组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 03:34