As follows to count the unique id_document values for the C # language:
Using LINQ:
var Consulta = (from x in db.Salesorders select id_documento).Distinct().Count();
Using Entity Framework:
var Consulta = db.Salesorders.GroupBy(x => x.id_documento)
.Select(x => x.First())
.ToList()
.Count;
As follows to count the unique id_document values for the VB language:
Using LINQ:
Dim NumElementosDistintos = (From x In db.Salesorders
Select x.id_documento)
.Distinct()
.Count
With the following query you can count the amount of total id_document in the table for the C # language:
Using LINQ:
var Consulta = (from x in db.Salesorders select id_documento).Count()
or
var count = db.Salesorders.Count();
With the following query you can count the amount of total id_document in the table for the VB language:
Using LINQ:
Dim NumElementos = (From x In db.SalesOrder Select x.id_documento).Count
You can see examples of how to use them in the following links:
Examples of the LINQ query In Spanish
101 Examples of using LINQ: Count - Simple and Count - Conditional
In English
101 Examples of using LINQ: Select - Simple In English
Aggregation Operations (Visual Basic) In English
How to: Count, Sum, or Average Data by Using LINQ (Visual Basic) In
English