In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is Linq to sql". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is Linq to sql".
What is Linq to sql?
Linq to sql (or DLINQ) is a part of LINQ (.NET language Integrated query), which is fully called .NET language integrated query based on relational data. It is used to manage relational data in the form of objects, and provides rich query functions. It forms a powerful LINQ with Linq to xml, Linq to objects, Linq to dataset, Linq to entities and so on.
To learn LINQ query syntax well, you have to understand some of the new features of C # 3.0, which are briefly described below.
Implied type local variables of Linq to sql basis
Var age = 26; var username = "zhuye"; var userlist = new [] {"a", "b", "c"}; foreach (var user in userlist) Console.WriteLine (user)
The var keyword, which is purely for lazy people, tells the compiler (for CLR, it won't know if you use var, coolies are from the compiler), you can infer its type, I don't care. But since you want the compiler to infer that a type must be assigned when it is declared, it cannot be a null value. Note that this can only be used for local variables, not for fields.
Anonymous types based on Linq to sql
Var data = new {username = "zhuye", age = 26}; Console.WriteLine ("username: {0} age: {1}", data.username, data.age)
Anonymous types allow developers to define inline types without having to explicitly define types. Often used with var, var is used to declare anonymous types. Defining a temporary anonymous type is very common in LINQ query syntax, and we can easily implement object conversion and projection.
The extension method of Linq to sql Foundation
Public static class helper {public static string MD5Hash (this string s) {return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (s, "MD5");} public static bool In (this object o, IEnumerable b) {foreach (object obj in b) {if (obj==o) return true;} return false;}} / / call extension method Console.WriteLine ("123456" .MD5Hash ()) Console.WriteLine ("1" .in (new [] {"1", "2", "3"}))
Many times we need to do some operations on the CLR type, because we cannot extend the methods of the CLR type, so we can only create some helper methods or generate subclasses. The extension approach enables these requirements to be implemented proudly, and is also the basis for the implementation of LINQ. It should be noted that extension methods can only be defined in static classes and are static methods. If the extension method name conflicts with the original method name, the extension method will become invalid.
Thank you for your reading, the above is the content of "what is Linq to sql", after the study of this article, I believe you have a deeper understanding of what Linq to sql is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.