sliverlight Arrays in LINQ filter data in a database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.