A simple trial of LINQ and Entity

Source: Internet
Author: User

Today I tried both the LINQ and Entity Framework respectively. I used MySQL and didn't want to use dblinq. So I tried to use the LINQ and entity together and wrote a simpleCodeAs shown below, we are pleasantly surprised to find that it can run.

In fact, I have been testing whether to easily control the connection and query of databases like ADO. net in the past after using LINQ and entity, and whether it will be as handy as writing SQL statements.

However, there are so many people who recommend it. I think there will always be some value for reference. I will study it from today on :)

 

  1   Youhuisouentities1 Context  =     New  Youhuisouentities1 ();
2
3 Int Num = Context. Products. Count < Products > ();
4 Console. writeline (Num. tostring ());
5
6 VaR Q = (From products P In Context. Products
7 Where P. cityid > 1
8 Select P). firstordefault ();
9
10 Console. writeline (Q. companyintroduction );

 

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.