In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the method of operating the database by Linq". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the method of operating the database by Linq"?
A simple example:
Public partial class simple: System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {int [] arr = new int [] {8, 5, 89, 3, 56, 4, 1, 58}; var m = from n in arr where n
< 5 orderby n select n; foreach (var n in m) { Response.Write(n); } } } 觉得这个n很牛,都不用定义就可以用了,而且他就知道这个n就是arr里的数字。 大概会用了,但是怎么用Linq操作数据库呢? 1.建立数据库 在使用Linq to SQL前,我们要将相应的数据库建好。在这个Demo中,使用的数据 库是SQL Server Express 2005。我们首先建立一个叫的数据库MyBulletin,及两个数据表:Category和Bulletin,分别表示 公告的分类和公告,建立方法不再赘述。 其中Category和Bulletin存在一个一对多的关联,表示一个分类下可以有多条公告。 2.建立Linq to SQL Classes文件 数据建好后,我们需要建立Linq to SQL Classes文件。这种文件是Linq to SQL框架的主要 文件,后面自动生成的实体类和ORM代码都存在于这个文件中。 我们打开VS2008,新建一个C# Class Labrary工程,名称为LinqToSqlDemo.Orm,建好后在工程上单击右键,选择"Add"->"New Item", select "Linq to SQL Classes" in the file type, and the file name is "DataClasses.dbml".
At this point, I believe you have a deeper understanding of "what is the method of Linq operating the database". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.