AsQueryable() method is used to get an IQueryable reference.
Let us see an example to find sum of integer values.
Firstly, set an integer array.
var arr = new int[] { 100, 200, 300, 400 };Now to find the sum, use the Queryable Sum() and AsQueryable() method.
Queryable.Sum(arr.AsQueryable());
The following is the complete code.
Example
using System;
using System.Linq;
class Demo {
static void Main() {
var arr = new int[] { 100, 200, 300, 400 };
int res = Queryable.Sum(arr.AsQueryable());
Console.WriteLine("Sum: "+res);
}
}Output
Sum: 1000