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 introduces how Linq reads data randomly, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Linq randomly reads data
Add this method to the system's freely generated obind p mapping code, and the same is true if it is user-written (or tool-generated) obind p mapping code. Here I'm going to talk about my own. The LINQ To Sql class generated by the system produces three files. Northwind.cs, Northwind.dbml.layout, Northwind.designer.cs
All we have to do is add the method NEWID () we need in Northwind.designer.cs, which is, of course, consistent with the function of NEWID () in the database.
The specific method code is as follows:
[System.Data.Linq.Mapping.DatabaseAttribute (Name= "Northwind")]
Public partial class NorthwindDataContext: System.Data.Linq.DataContext
{
Private static System.Data.Linq.Mapping.
MappingSource mappingSource = new AttributeMappingSource ()
/ / add to the automatically generated mapping code
[Function (Name = "NEWID", IsComposable = true)]
Public Guid NEWID ()
{
Return ((Guid) (this.ExecuteMethodCall (this)
((MethodInfo) (MethodInfo.GetCurrentMethod () .ReturnValue))
}
/ / the following generated code is slightly..
By regenerating and writing this, our access implementation becomes easy, and it is used in the same way as traditional access principles.
Db = new NorthwindDataContext (); var result = (from c in db.Customers orderby db.NEWID () select c) .Take (10); foreach (var item in result) Console.WriteLine (item.CompanyName); Console.ReadLine () Thank you for reading this article carefully. I hope the article "how to read data randomly from Linq" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you 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.