Advanced Queries for LINQ:
Fuzzy search
Con. Car.where (R=>r.name.contains (CNAME)). ToList ();
To.. Beginning
Con.car.Where (r = R.name.startswith (TextBox1.Text)). ToList ();
To.. End
Con.car.Where (r = R.name.endswith (TextBox1.Text)). ToList ();
To find the maximum value
Con.car.Max (r = r.price * r.oil). ToString ();
Minimum value
Con.car.Min (r = r.price). ToString ();
Sum
Con.car.Sum (r = r.price). ToString ();
Average
Con.car.Average (r = r.price). ToString ();
Ascending
Con.car.OrderBy (r = r.price). ToList ();
Descending
Con.car.OrderByDescending (r = r.price). ToList ();
Page out
int pagenum = Convert.ToInt32 (pagecount_label.text) + 1;
Repeater1.datasource = Con.car.Skip ((pageNum-1) * PageCount). Take (PageCount);
Repeater1.databind ();
Pagecount_label.text = Pagenum.tostring ();
Combination Query
list<car> list = Con.car.ToList ();
if (TextBox2.Text! = "")
{
List<car> List1 = con.car.Where (r = r.name.contains (TextBox2.Text)). ToList ();
List = list. Intersect (List1). ToList ();
}
if (TextBox3.Text! = "")
{
List<car> List1 = con.car.Where (r = R.oil = = Convert.todecimal (textbox3.text)). ToList ();
List = list. Intersect (List1). ToList ();
}
if (Textbox4.text! = "")
{
List<car> List1 = con.car.Where (r = r.powers = = Convert.ToInt32 (textbox4.text)). ToList ();
List = list. Intersect (List1). ToList ();
}
Repeater1.datasource = list;
Repeater1.databind ();
C#webform LinQ