Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of LINQ to SQL?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what is the use of LINQ to SQL for you. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

LINQ to SQL currently only supports SQL Server (a version of SQL Server Compact is under development), and there are signs that it may also support the official statement of DB2,Informix IDS,Oracle that they are following the progress of Linq, VistaDB, MySQL. But it can be foreseen that if Linq is to RTM at the end of 2007, there is not much time to support other databases. I even read on Weblog that the support for SQL Server Compact is not included in the LINQ v1 release plan. However, MS,IBM,Oracle, if they are really determined to do it, then time is not a problem. If the above conclusion is true, then my view is that LINQ to SQL is not ORM in a pure sense, because it does not support enough types and types of databases.

From the advanced nature and difficulty of the technology, Java Persistence API and Linq are two technologies to solve problems at different levels, and from the developer's point of view, Java Persistence API is not Touch to the level that Linq focuses on. As I said above, from the perspective of programming language, LINQ is supported by * layer compilers and development languages, while Java Persistence is not so low-level. In addition, for the existing ORM technologies of Java Persistence API,Adopt, such as Hibernate, TopLink, and JDO, Java Persistence API is more like a new API built by the aggregators of existing Java ORM, while LINQ to SQL,LINQ to DataSet,LINQ to XML,LINQ to Entities,LINQ to Object,LINQ to Flickr, LINQ to NHibernate and LINQ to LDAP are all fixed on the board, so from a design point of view, LINQ is more magnificent and macro, because once supported from the compiler and development language level Then the degree of its integration, penetration and application is quite high, and I think its "affinity" is quite strong.

ADO.NET Entity Framework (ADO EF) is more of an entity or conceptual design service framework, which maps the relationship between real entities and entities to the object layer, CLR classes and their relationships, and even ADO.NET Team avoids making ADO EF conceptually a design tool similar to ORM. ADO EF emphasizes the flexible, independent and loose coupling of three layers {concept layer / entity layer (Conceptual layer), metadata layer (Source schema) and mapping layer (Mapping layer)}, so that you can map a concept layer / entity layer to multiple different databases by defining multiple mapping layers, which LINQ to SQL cannot do. First of all, LINQ to SQL does not support multiple inheritance of entities (supports limited inheritance). There are even comments that LINQ to SQL RTM will not be supported by many-many relationships before, and LINQ to SQL is more likely to use the dbml attribute to bind to specific database fields of a table. In other words, LINQ to SQL does not have so many layers, and it emphasizes the structured support of programming languages for data query and analysis (from the programming language level).

In theory, ADO EF is a framework of Hao Da Engineering, which can better support the development of popular Domain Model Driven, which requires that it has three layers of design tools to show your design, highlight and locate your entity relationship, and that the tool can generate database scripts or reverse engineering according to the entity layer. At the same time, it needs extremely high precision and very Smart code generation tools and interfaces. At present, the thin EDM Wizard of Orcas Beta1 is simply not enough to meet these requirements. The earlier release of Entity Data Model Designer Prototype has become a monument and can not be surpassed. Look at this video of a more beautiful designer-- very cool.

"Entity Framework the March CTP and Beta 1 are almost identical. There's some last bit of features that we're busily working on now that will appear in Beta2 and the Orcas Release "means that ADO EF has not changed much in Orcas Beta1 and March CTP (ccBoy suggests that you can focus on LINQ to SQL in Orcas Beta1). Some people even think that a major sign of the progress of Orcas's Entity Framework is that Orcas can provide excellent EDM Designer to meet the engineering requirements we mentioned above, so Orcas Beta2 will be a major milestone for ADO EF. So the conclusion is that the focus of ADO EF and LINQ to SQL is very different, compared with ADO EF development or performance will be more important, but ADO EF tends to Domain Model Driven and support more popular databases or data sources, but ADO EF is definitely not a simple ORM Tools, it will be understood as entity framework and object service layer technology, in which LINQ becomes a very small low-level supporting technology in ADO EF. I just talked about LINQ's affinity.

From the perspective of technology development, if your entity / business model (or problem domain) does not match the existing data model, you need to consider ADO EF. Anyway, if your entity / business model (or problem domain) matches the existing data model, then LINQ to SQL will be a good choice. As for LINQ to Entities and LINQ to SQL, as mentioned above, it is quite clear (think of the translated version) Let me sum up, the common point is that LINQ to Entities is a superset or Superset of LINQ to SQL. You can see that LINQ to Entities is heavier in Feature comparison between the two. It runs or lets you run on a conceptual data model (Conceptual data model), and your query for objects takes place at this layer.

So the difference is that when you use LINQ to SQL, your mapping, the resulting CLR/.NET classes are tightly coupled or bound to your data / database model, and if you change the object model, you have to modify these classes directly, and if the data model changes, you use regenerated object code, while ADO EF builds a conceptual layer / entity layer on the data / database model. This allows you to first define the concept layer / entity layer, then create a script (description) for the data / database, and then establish a logical mapping between your entity and the data in a reflection layer. this makes a good degree of coupling and isolation between the business and the data source. While LINQ to SQL cannot achieve this effect, LINQ to Entities also comes with some other strengths provided by ADO EF directly, such as entity inheritance (Entity Inheritance) and entity combination (Entity Composition).

More often than not, Entity SQL (eSQL) is a variant of the SQL statement that is completely oriented to the query language (Query Language), but it corresponds to the query of the entity data model, the query of the entity and the attributes in the entity, and more often the Entity SQL is the Object Services facing the ADO EF. The object service is a service in ADO EF that can work and operate the entity like an object. In fact, Object Services is often a de facto in-memory object database. Of course, you can only query objects or entities here and get them, you can't use SQL DML statements like Update or Deleted objects or entities (of course, in the future, v1 version is to do a good query), when we want to interact with the concept layer / entity layer mentioned above, * you can use Entity SQL (eSQL), and second you need to use LINQ to Entities,Entity SQL (eSQL) is text and character, so it supports composable. For example, subquery, and then you understand all the LINQ to XXXX, which actually means how you can quickly enjoy the data integration and query capabilities and convenience of LINQ against XXXX (data source or object source) at the programming language level (built-in expressions, operation statements, code productivity, performance, etc.).

* is Entity Client, a new type of API, that is, it is specially used to access physical sources or entity data models. Entity Client uses its own language-Entity SQL (eSQL), which is also another data source provided by ADO.NET to provide drivers. You can understand Entity Client as you understand SqlClient. It is another way to access the entity data model. It has two meanings. The result returned by EntityClient is dbDataReader, which means that you can use unified or code experience that you are very familiar with, such as you use ADO.NET to manipulate SQL Server, Oracle,MySQL skills to process the query data skillfully, or to flip over the data like a cold dish.

As consultants and practitioners, we have to do it first, and then we are faced with giving ourselves and others some advice in the next six months to a year:

1. The emergence of LINQ shows a new tension of the * layer. The most important energy and power of any modern programming language is the compiler of this language. The emergence of LINQ puts an end to all the debates about the advanced nature of the language. As a technician, you need to be aware of this change and its impact.

two。 From the current version of Orcas Beta1, it is recommended that you give priority to learning C # 3.0 and LINQ in the next 6-12 months, and master new expressions, grammars and sentences, which are the same basic skills as For,IF statements in future programming languages. Every developer needs to be proficient in using these statements, and of course he can study and understand the implementation and principle behind these new statements.

3. For those intermediate developers who have mastered LINQ to SQL 3.0 and LINQ, in LINQ to SQL (LINQ2SQL) and ADO.NET Entity Framework, priority can be given to learning and studying LINQ to SQL, and putting this technology into practice in projects or applications.

Before 4.ADO.NET Entity Frameworkd's Entity Desiger comes out, keep paying attention to it without spending too much time. In addition, from a developer's point of view, ADO EF is not necessary, even if designers, especially Domain Model Drivening personnel, need to pay attention to and prepare it. Of course, it is not too late to consider and study these after six months.

The release date of 5.Visual Studio Orcas is still a key factor. It can be predicted that C # 3.0 and LINQ will be released at the time when people's expectations and wishes come true, but how many parts related to ADO.NET Entity Framework need to be observed and noted, but on the other hand, with LINQ and LINQ to SQL, we already feel that it is worth it.

6. Consider the impact of new features on application architecture in your project, and practice the application of LINQ and C# under the traditional development technology of ASP.NET as much as possible

7. Continue to focus on Visual Studio Orcas, as .NET 3.5 or .NET 4.0 has begun to move towards a more mature, advanced and confident side

This is the end of this article on "what's the use of LINQ to SQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

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: 251

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report