“The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.” error in WCF


Hi,

while doing test with WCF application ,I was getting error like this

The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

Then we should have to solve this error like this

1. Check the service is running or not. If not then rebuild the solution

2.Add this line in web confi file

<behaviors>
<serviceBehaviors>
<behavior name=””>
<serviceMetadata httpGetEnabled=”true”/>

<dataContractSerializer maxItemsInObjectGraph=”2147483647″/>

<serviceDebug includeExceptionDetailInFaults=”false”/>

</behavior>

Advertisements
Posted in Errors, WCF. 5 Comments »

How to do CRUD operation in asp.net using WCF?


Hi

I hope that you are know the basic concept of creating and consuming WCF. If you don’t know then please refer my previous post
Wcf sample-code in asp.net 3.5.

For simplicity i have written General sql query. Please change into store procedure for better performance.

For doing this task, we have to do like this

Step1:Write the code in “Iservice.cs” like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

// NOTE: If you change the interface name “IService2” here, you must also update the reference to “IService2” in Web.config.
[ServiceContract]
public interface IService
{
[OperationContract]

List<Emp> GetAllEmpName();

[OperationContract]
int SaveEmp(Emp objEmp);

[OperationContract]
int DeleteEmp(int Id);

[OperationContract]
List<Emp> GetSelectedEmp(int Id);

[OperationContract]
int UpdateSelectedEmp(Emp objEmp);

}

[DataContract]
public class Emp
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string EmpName { get; set; }
[DataMember]
public string EmpSal { get; set; }

}

Step2 write the code in “Service.cs” like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using System.Data.SqlClient;

// NOTE: If you change the class name “Service2” here, you must also update the reference to “Service2” in Web.config.
public class Service : IService
{
public void DoWork()
{
}

//For Fetching All EmpName

public List<Emp> GetAllEmpName()
{
List<Emp> Emps = new List<Emp>();
using (SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True”))
{

using (SqlCommand cmd = new SqlCommand(“Select Id,EmpName,EmpSal from tblEmp”, con))
{
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Emp emp1 = new Emp();
emp1.Id = int.Parse(dr[“Id”].ToString());
emp1.EmpName = Convert.ToString(dr[“EmpName”]);
emp1.EmpSal = Convert.ToString(dr[“EmpSal”]);
Emps.Add(emp1);
}
con.Close();
return Emps;
}
}
}

//For saving Emp Detail

public int SaveEmp(Emp objEmp)
{
using (SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True”))
{
using (SqlCommand cmd = new SqlCommand(“Insert into tblEmp(EmpName,EmpSal)Values(@EmpName,@EmpSal)”, con))
{
cmd.Parameters.AddWithValue(“@EmpName”, objEmp.EmpName);
cmd.Parameters.AddWithValue(“@EmpSal”, objEmp.EmpSal);
con.Open();
int a = cmd.ExecuteNonQuery();
con.Close();
return a;
}

}
}

//For Deleting Emp Record

public int DeleteEmp(int Id)
{
using (SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True”))
{
using (SqlCommand cmd = new SqlCommand(“Delete from tblEmp where Id=@Id”, con))
{
cmd.Parameters.AddWithValue(“@Id”, Id);
con.Open();
int a = cmd.ExecuteNonQuery();
con.Close();
return a;

}

}

}

//For Updating Emp Detail

public int UpdateSelectedEmp(Emp objEmp)
{
using (SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True”))
{
using (SqlCommand cmd = new SqlCommand(“Update tblEmp set EmpName=@EmpName,EmpSal=@EmpSal where Id=@Id”, con))
{
cmd.Parameters.AddWithValue(“@Id”, objEmp.Id);
cmd.Parameters.AddWithValue(“@EmpName”, objEmp.EmpName);
cmd.Parameters.AddWithValue(“@EmpSal”, objEmp.EmpSal);

con.Open();
int a = cmd.ExecuteNonQuery();
con.Close();
return a;
}

}

}

//For Fetching Particular EmpDetail

public List<Emp> GetSelectedEmp(int Id)
{
List<Emp> Emps = new List<Emp>();
using (SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True”))
{

using (SqlCommand cmd = new SqlCommand(“Select *from tblEmp where Id=@Id”, con))
{
con.Open();
cmd.Parameters.AddWithValue(“@Id”, Id);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Emp emp1 = new Emp();
emp1.Id = int.Parse(dr[“Id”].ToString());
emp1.EmpName = Convert.ToString(dr[“EmpName”]);
emp1.EmpSal = Convert.ToString(dr[“EmpSal”]);
Emps.Add(emp1);
}
con.Close();
return Emps;
}
}
}

}

Step3: Design default page like this

<div style=”margin-left:150px”>
<asp:MultiView ID=”Mv1″ runat=”server”>
<asp:View ID=”Vw1″ runat=”server”>
<table>
<tr>
<td>
&nbsp;</td>
<td align=”right”>
<asp:LinkButton ID=”LinkButton1″ runat=”server” onclick=”LinkButton1_Click”
Width=”88px”>View All</asp:LinkButton>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
EmpName</td>
<td>
<asp:TextBox ID=”txtEmpName” runat=”server”></asp:TextBox>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
EmpSal</td>
<td>
<asp:TextBox ID=”txtEmpSal” runat=”server”></asp:TextBox>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
<asp:Button ID=”BtnSubmit” runat=”server” Text=”Submit”
onclick=”BtnSubmit_Click” style=”height: 26px” />
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
<asp:Label ID=”lblmsg” runat=”server”></asp:Label>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
<asp:HiddenField ID=”HiddenField1″ runat=”server” />
</td>
<td>
&nbsp;</td>
</tr>
</table>
</asp:View>

<asp:View ID=”Vw2″ runat=”server”>

<asp:LinkButton ID=”lnkBack” Text=”Add New Record” runat=”server”
onclick=”lnkBack_Click” /><br /><br />

<asp:GridView ID=”GridView1″  AllowPaging=”true” PageSize=”10″ runat=”server” AutoGenerateColumns=”False”
CellPadding=”4″ ForeColor=”#333333″ GridLines=”None”
onpageindexchanging=”GridView1_PageIndexChanging”
onrowcommand=”GridView1_RowCommand” onrowdeleting=”GridView1_RowDeleting”
onrowediting=”GridView1_RowEditing” Width=”455px”>
<RowStyle BackColor=”#EFF3FB” />
<Columns>
<asp:TemplateField HeaderText=”SI”>
<ItemTemplate>

<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText=”EmpName” DataField=”EmpName” />
<asp:BoundField HeaderText=”EmpSal” DataField=”EmpSal” />
<asp:TemplateField HeaderText=”Action”>

<ItemTemplate>

<asp:LinkButton ID=”lnkEdit” runat=”server” Text=”Edit” CausesValidation=”false” CommandName=”Edit” CommandArgument='<%# Eval(“Id”) %>’ OnClientClick=”return confirm(‘Are you sure?’)” />
<asp:LinkButton runat=”server” ID=”lnk_Delete” Text=”Delete” CausesValidation=”false” CommandName=”Delete” CommandArgument='<%# Eval(“Id”) %>’ OnClientClick=”return confirm(‘Are you sure?’)”/>

</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />
<PagerStyle BackColor=”#2461BF” ForeColor=”White” HorizontalAlign=”Center” />
<SelectedRowStyle BackColor=”#D1DDF1″ Font-Bold=”True” ForeColor=”#333333″ />
<HeaderStyle BackColor=”#507CD1″ Font-Bold=”True” ForeColor=”White” />
<EditRowStyle BackColor=”#2461BF” />
<AlternatingRowStyle BackColor=”White” />
</asp:GridView>
</asp:View>
</asp:MultiView>

<br />

</div>

step 4: write the code in code behind file like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Mv1.ActiveViewIndex = 0;

}

}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//this is used for paging in gridview
GridView1.PageIndex = e.NewPageIndex;
fillGrid();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == “Delete”)
{
//This is used for deleting operation

int id1 = Convert.ToInt32(e.CommandArgument);

using (ShowEmpData.ServiceClient ws = new ShowEmpData.ServiceClient())
{

int a = ws.DeleteEmp(id1);
if (a == 1)
{

fillGrid();
Mv1.ActiveViewIndex = 1;
}
}

}
else if (e.CommandName == “Edit”)
{
//this is used for displaying particular record for updation work
int id1 = Convert.ToInt32(e.CommandArgument);
using (ShowEmpData.ServiceClient ws = new ShowEmpData.ServiceClient())
{

var Empobj = ws.GetSelectedEmp(id1);
txtEmpName.Text = Empobj[0].EmpName.ToString();
txtEmpSal.Text = Empobj[0].EmpSal.ToString();
HiddenField1.Value = Empobj[0].Id.ToString();
BtnSubmit.Text = “Update”;
lblmsg.Text = “”;
Mv1.ActiveViewIndex = 0;
}

}

}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{

}

//This is used for filling gridview

protected void fillGrid()
{

ShowEmpData.ServiceClient ws = new ShowEmpData.ServiceClient();
GridView1.DataSource = ws.GetAllEmpName();
GridView1.DataBind();

}

protected void BtnSubmit_Click(object sender, EventArgs e)
{
if (BtnSubmit.Text == “Submit”)
{
using (ShowEmpData.ServiceClient ws = new ShowEmpData.ServiceClient())
{
// This is used for Insertion of records

ShowEmpData.Emp objemp = new ShowEmpData.Emp();
objemp.EmpName = txtEmpName.Text;
objemp.EmpSal = txtEmpSal.Text;
int a = ws.SaveEmp(objemp);
if (a == 1)
{

txtEmpName.Text = “”;
txtEmpSal.Text = “”;
fillGrid();
Mv1.ActiveViewIndex = 1;

}
}

}
else
{
// This is used for updating the records

using (ShowEmpData.ServiceClient ws = new ShowEmpData.ServiceClient())
{
ShowEmpData.Emp objemp = new ShowEmpData.Emp();
objemp.Id = Convert.ToInt32(HiddenField1.Value);
objemp.EmpName = txtEmpName.Text;
objemp.EmpSal = txtEmpSal.Text;
int a = ws.UpdateSelectedEmp(objemp);

if (a == 1)
{

txtEmpName.Text = “”;
txtEmpSal.Text = “”;
fillGrid();
Mv1.ActiveViewIndex = 1;

}
}

}

}

protected void LinkButton1_Click(object sender, EventArgs e)
{
Mv1.ActiveViewIndex = 1;
fillGrid();
}
protected void lnkBack_Click(object sender, EventArgs e)
{
Mv1.ActiveViewIndex = 0;
BtnSubmit.Text = “Submit”;
}

}

“Could not load file or assembly Error” in WCF


Hi

While creating CRUD operation in asp.net. I was getting error like this

Could not load file or assembly ‘App_Web_meat25oe, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.
The system cannot find the file specified.

Then i solve the problem , by doing the following task

1. Clean the solution

2.Rebuild the solution

3. Save the service page

 

If you have some better way to solve the problem,Please share with me.

 

The request channel timed out while waiting for a reply after 00:00:59.9989999,Error in WCF


Hi

while creating CRUD operation in Asp.net with WCF, I was getting error like this

The request channel timed out while waiting for a reply after  00:00:59.9989999. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

Then I solve the problem while increasing the time interval like this

<binding name=”BasicHttpBinding_IService” closeTimeout=”00:10:00″ openTimeout=”00:10:00″ receiveTimeout=”00:10:00″ sendTimeout=”00:10:00″ allowCookies=”false” bypassProxyOnLocal=”false” hostNameComparisonMode=”StrongWildcard” maxBufferSize=”65536″ maxBufferPoolSize=”524288″ maxReceivedMessageSize=”65536″ messageEncoding=”Text” textEncoding=”utf-8″ transferMode=”Buffered” useDefaultWebProxy=”true”>
<readerQuotas maxDepth=”32″ maxStringContentLength=”8192″ maxArrayLength=”16384″ maxBytesPerRead=”4096″ maxNameTableCharCount=”16384″/>
<security mode=”None”>
<transport clientCredentialType=”None” proxyCredentialType=”None” realm=””/>
<message clientCredentialType=”UserName” algorithmSuite=”Default”/>
</security>
</binding>

 

If you have some better way to solve the problem,Please share with me.

How to delete multiple rows in Gridview?


Hi

You can do this like.

step1. Include the checkbox field in header of Gridview and write the JavaScript code to select the multiple rows of Gridview like this

<%@ Page Language=”C#” AutoEventWireup=”true”  CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head runat=”server”>
<title></title>

<script type = “text/javascript”>

function checkAll(objRef)
{

var GridView = objRef.parentNode.parentNode.parentNode;

var inputList = GridView.getElementsByTagName(“input”);

for (var i = 0; i < inputList.length; i++)
{

//Get the Cell To find out ColumnIndex

var row = inputList[i].parentNode.parentNode;

if (inputList[i].type == “checkbox” && objRef != inputList[i])
{

if (objRef.checked)
{

row.style.backgroundColor = “Silver”;
inputList[i].checked = true;

}

else
{
inputList[i].checked = false;
row.style.backgroundColor = “white”;

}

}

}

}

</script>

</head>
<body>
<form id=”form1″ runat=”server”>

<div style=”margin-left:200px;”>

<asp:GridView ID=”GridView1″ runat=”server”
AutoGenerateColumns=”False”>
<Columns>
<asp:TemplateField HeaderText=”Select”>

<HeaderTemplate>

<asp:CheckBox ID=”chkAll” runat=”server”

onclick = “checkAll(this);” />

</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID=”chkBox1″  runat=”server” />
<asp:Label ID=”lblId” runat=”server” Text='<%# Eval(“Id”) %>’ Visible=”false” />

</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText=”SI.No”>
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField HeaderText=”EmpName” DataField=”EmpName” />
<asp:BoundField HeaderText=”EmpSal” DataField=”EmpSal” />
</Columns>

</asp:GridView>

<asp:Button ID=”BtnDelete” runat=”server” Text=”Delete”
CausesValidation=”false” OnClientClick=”return confirm(‘Are you sure?’)”
onclick=”BtnDelete_Click” />

</div>

</form>
</body>
</html>

Step2: Write the code for checking selected row of gridview and take the Id of that row.

if  check box checked is true then delete that row of gridview

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillGrid();
}

}
protected void FillGrid()
{
using (SqlConnection con = new SqlConnection(“Data Source=.;Initial Catalog=Test;Integrated Security=True”))
{
using (SqlCommand cmd = new SqlCommand(“Select top 10 *from tblEmp”, con))
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
protected void BtnDelete_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl(“chkBox1”);
Label lbl=(Label)row.FindControl(“lblId”);
string uid =lbl.Text ;
if (cb.Checked)
{
using( SqlConnection con = new SqlConnection(“Data Source=.;Initial Catalog=Test;Integrated Security=True”))
{

using (SqlCommand cmd = new SqlCommand(“Delete from tblEmp where Id=@Id”, con))
{

cmd.Parameters.AddWithValue(“@Id”, uid);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
FillGrid();
}

}

}
}
}
}

Caching in asp.net


Definition
Caching is the concept of storing frequently used data in the cache memory. It is mainly useful when we have to fetch same data again and again.

Advantages:
• It will increase the performance of website
• It will avoid the server overloading problem.

There are 3 type of Caching in asp.net

A. Output Caching
B. Fragment Caching
C. Data Caching

Output Caching

This is the simplest type of caching. It will cache the final rendered HTML page that is send to the client. When the same page is requested again, the control objects are not created, the page life cycle will not start and none of code will execute. So it will increase the performance of website.
Syntax for using Output Caching:
Wrire this syntax in page directive
<%@ OutputCache Duration=”20″ VaryByParam=”None” %>
Here page will cache upto 20 Seconds after that page will expire.

Caching at Client side:

In this case browser will store the page and it will reuse when somebody is requesting same page .
Syntax for Client caching:
<%@ OutputCache Duration=”20″ VaryByParam=”None” Location=”Client” %>

Caching and the Query String
For example if we have used Output caching and there is requirement to display dynamic page on basis of Query string then the above syntax will not give the correct output. It will cache the same page every time. So we have to write the syntax like this
<%@ OutputCache Duration=”20″ VaryByParam=”*” %>

Caching with Specific Parameters

For example if we have used Output caching and there is requirement to display dynamic page on basis of some parameter or some dropdown field or some textbox field then the above syntax will not give the correct output. It will cache the same page every time. So we have to write the syntax like this
<%@ OutputCache Duration=”20″ VaryByParam=”txtName” %>
Here txtName is the parameter. It will cache the page on basis of txtName

Here is one sample example

Step1: Implement the caching syntax in aspx page like this

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”OutPutCaching.aspx.cs” Inherits=”OutPutCaching” %>

<%@ OutputCache Duration=”20″ VaryByParam=”txtName” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

<title></title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div style=”margin-left:200px”>

<asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>

<br />

<br />

<asp:Button ID=”BtnSubmit” runat=”server” Text=”Submit”

onclick=”BtnSubmit_Click” />

<br />

<br />

<asp:GridView ID=”GridView1″ runat=”server”>

</asp:GridView>

<br />

</div>

</form>

</body>

</html>

Step2: Write the code behind page like this

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

public partial class OutPutCaching : System.Web.UI.Page

{

SqlConnection con = new SqlConnection(“Data Source=.;Initial Catalog=Test;Integrated Security=True”);

protected void Page_Load(object sender, EventArgs e)

{

}

protected void BtnSubmit_Click(object sender, EventArgs e)

{

using (SqlCommand cmd = new SqlCommand(“Select *from tblEmp where EmpName=@EmpName”, con))

{

cmd.Parameters.AddWithValue(“@EmpName”, txtName.Text);

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataTable dt = new DataTable();

da.Fill(dt);

if (dt.Rows.Count > 0)

{

GridView1.DataSource = dt;

GridView1.DataBind();

}

else

{

GridView1.DataSource = null;

GridView1.DataBind();

}

}

}

}

Then we will get the exact o/p while textbox field is  changing.

Fragment Caching

If we have to cache the portion of page then we can use fragment caching. This is mainly used if we have to display the advertisement on home page and one page refresh that image is changing.

Data Caching:

Data caching is the most flexible type of caching. If we have to load some data from database and we have to use that data frequently, then we can store that data in cache for some time period and use it repeatedly without calling the database. So it will reduce the server overload.

Sample code for data Caching:

Step1: In design page take one gridview and label control

Step2: Create some table with data for example tblEmp

Step3: Write the code in code behind for caching data in dataset like this

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

GridView1.DataSource = getdataset();

GridView1.DataBind();

}

}

protected DataSet getdataset()

{

DataSet ds = (DataSet)Cache[“tblEmp”];

if (ds == null)

{

ds = EmpNameRetrival();

//caching for 10 secound

Cache.Insert(“tblEmp”, ds, null, DateTime.MaxValue, TimeSpan.FromSeconds(10));

Label1.Text = “Created and added to cache”;

}

else

{

Label1.Text = “Retrival from cache is happening”;

}

return ds;

}

protected DataSet EmpNameRetrival()

{

using(SqlConnection con=new SqlConnection(“Data Source=.;Initial Catalog=Test;Integrated Security=True”))

{

using (SqlCommand cmd = new SqlCommand(“Select top 10 *from tblEmp”, con))

{

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds,”tblEmp”);

return ds;

}

}

}

}

Step4: Compile the project. Then you will get first time o/p  like this

After refress, you will get o/p like this

Some useful Clauses and Methods of LINQ, Part #8


LINQ supports the following clauses that you can use in a query:

1. from—Enables you to specify the data source and a variable for iterating over the

data source (a range variable).

2.where—Enables you to filter the results of a query.

3.select—Enables you to specify the items included in the results of the query.

4.group—Enables you to group related values by a common key.

5.into—Enables you to store the results of a group or join into a temporary variable.

6.orderby—Enables you to order query results in ascending or descending order.

7.join—Enables you to join two data sources using a common key.

8.let—Enables you to create a temporary variable to represent subquery results.

List of some of the more interesting and useful methods  in LINQ:

. Aggregate()—Enables you to apply a function to every item in a sequence.

. Average()—Returns the average value of every item in a sequence.

. Count()—Returns the count of items from a sequence.

. Distinct()—Returns distinct items from a sequence.

. Max()—Returns the maximum value from a sequence.

. Min()—Returns the minimum value from a sequence.

. Select()—Returns certain items or properties from a sequence.

. Single()—Returns a single value from a sequence.

. Skip()—Enables you to skip a certain number of items in a sequence and return the remaining elements.

. Take()—Enables you to return a certain number of elements from a sequence.

. Where()—Enables you to filter the elements in a sequence.