First of all, What is LINQ?
LINQ is Language Integrated query (language-integrated queries), which is a new feature that integrates into C # and Visual Basic.NET to provide the ability to query data in these languages.
It is. NET Framework, which allows us to query the data collection in the same way as a database query.
With LINQ technology, we can query any form of data using a SQL-like syntax.
Now, let's talk about my work.
Arrays in LINQ filter data in a database
Public List GetList1 (string cardphone,string[] carno)
{
var q = from R in DB (). Tab_tel_advisory
where R.cust_tel = = Cardphone | | Carno.contains (R.car_no)
Select New Teladvisory
{
ID = R.id,
Custtel = R.cust_tel,
CustName = R.cust_name,
Carno = R.car_no,
Advisorycontent = R.advisory_content,
Advisorydate = R.advisory_date,
Answerresult = R.answer_result,
Server = R.server,
};
return Q.tolist ();
}
The SubmitChanges method is called in LINQ for additions and deletions.
public bool ResetPassword (usertype type, int userId, string newcryptpassword)
{
var db = db ();
Try
{
Switch (type)
{
Case usertype. Employees:
{
var tab = db. Tab_employee. Single (r = r.id = = userId);
tab. Login_pwd = Newcryptpassword;
Break
}
Case Usertype. Partners:
{
var tab = db. Tab_partner. Single (r = r.id = = userId);
tab. Login_pwd = Newcryptpassword;
Break
}
}
Db. SubmitChanges ();
return true;
}
Catch
{
return false;
}
}
Db.account.DeleteOnSubmit (account);
Db.account.InsertOnSubmit (account);
Db. SubmitChanges ();
Search criteria in LINQ, parameters passed in are empty or have values, or are keywords
Query = (from R in Db.) Tab_partner
WHERE ((Partnertype! =-1 && r.partner_type = = Partnertype) | | partnertype = =-1)
&& ((Searchkey! = "" && r.partner_name. IndexOf (Searchkey) >-1) | | Searchkey = = "")
R.partner_type Ascending
Problems with LINQ to SQL paging
Skip (100) represents skipping 100 lines. Start paging from line 101th;
Take (10) indicates how many rows are paged; PageSize the number of data bars to display per page
Q.skip (PageSize * (CurrentPage-1)). Take (PageSize). ToList ();
sliverlight Arrays in LINQ filter data in a database