Hi ahsan.ali,
Check this example. Now please take its reference and correct your code. Change the code according to your column datatype.
Database
For this example I have used of NorthWind database that you can download using the link given below.
Download Northwind Database
SQL
SELECT SUM(ReportsTo) AS TotalAmountPaid
FROM Employees
WHERE EmployeeID IN (1,2,5,6) and Extension = 428
Output
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
NorthwindModel.NorthwindEntities entities = new NorthwindModel.NorthwindEntities();
var id = new[] { 1, 2, 5, 6 };
string extension = "428";
Response.Write("TotalAmountPaid : " + entities.Employees.Where(x => id.Contains(x.EmployeeID) && x.Extension == extension).Sum(x => x.ReportsTo));
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim entities As NorthwindModel.NorthwindEntities = New NorthwindModel.NorthwindEntities()
Dim id = {1, 2, 5, 6}
Dim extension As String = "428"
Response.Write("TotalAmountPaid : " & entities.Employees.Where(Function(x) id.Contains(x.EmployeeID) AndAlso x.Extension = extension).Sum(Function(x) x.ReportsTo))
End Sub
Output
TotalAmountPaid : 5