Showing posts with label LINQ. Show all posts
Showing posts with label LINQ. Show all posts

Tuesday, 31 March 2015

How to get Row Index using LINQ in C#?

In this post, Get the row index using LINQ in C# based on column

Ex :

  int rowindex = new System.Data.DataView(datatable).ToTable(false, new[] { "Columname" })
                .AsEnumerable()
                .Select(row => row.Field<string>("Columname")) .ToList()
                .FindIndex(col => col == variablewithvalue);


Happy Coding:)

How to get count of rows based on column using LINQ in C#?

In this Post, Get count of rows using LINQ in C# based on column.

Ex :
int VenueCount = datatable.AsEnumerable().Count(p => p.Field<string>("columname") == svalue);

Where,

svalue is a varaible contain string


Happy Coding:)

How to get Maximum Value using Linq based on Column?

In this post, Get the maximum value using LINQ based on Column in C#.

Ex :
int maxvalue = datatable.AsEnumerable().Max(r => r.Field<string>("Columname"));

Happy Coding:)