In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.