Linq Gruping Dynamically
-
sexta-feira, 20 de abril de 2012 06:08
Hi i want to write dynamic Grouping for my code.
string cc=GroupColumnName.LastOrDefault().ToString()
string dd = "Amit";
var categories =
from p in kk //KK List.
group p by new
{
Sec = cc
} into g
select new { Category = g.Key, TotalUnitsInStock = g.Sum(p =>dd //Dynamic Columnname) };how can I achieve this.
Amitsp
Todas as Respostas
-
sábado, 21 de abril de 2012 00:23
Hi Amit,
You can build dynamic LINQ queries using the LINQ Dynamic Query Library. Have a look here: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
Regards,
Tyler
- Sugerido como Resposta Tyler_A terça-feira, 24 de abril de 2012 14:26
- Não Sugerido como Resposta Amit Prajapati quarta-feira, 25 de abril de 2012 05:09
-
quarta-feira, 25 de abril de 2012 05:09Hi I seen that URL but not related with Grouping? I need grouping with dynamic value.
Amitsp
-
segunda-feira, 7 de maio de 2012 06:57Moderador
Hi Amit,
You can refer this link here: http://blogs.msdn.com/b/mitsu/archive/2008/02/07/linq-groupbymany-dynamically.aspx
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


