High imitation entity Framework? Linq to SQL also has spring!

Source: Internet
Author: User

the development of this framework, mainly originated from a lot of users who use ALINQ or LINQ to SQL, often complained to me that they are really cool to use, but dynamic queries are so tangled. This framework is mainly to solve the problem of dynamic queries encountered by customers. So far, has been on and off for more than a year, writing this framework, full of challenges and fun. Of course, now more feel, can write the document, is more challenging. Most programmers have always been very concerned about writing documents, and I am a part of it. However, working with clients for a long time has made me realize that documentation is very important and that it is not easy to write a document well. This release, more focus on the preparation of the document. So, in this release package, you will see a very carefully written, very detailed document.

As you can see on the trail, Alinq Dynamic is a high-imitation Entity Framework, why should it be a cottage, rather than create another syntax?

1) do not want to increase the user's learning burden, now the framework is enough. Every grammar, one more study cost.

2) I think the Entity SQL is very well designed, very close to SQL, and the user basically does not need to spend any time to get started. Who wouldn't write about SQL?

So I think, in order to innovate and innovation is a meaningless thing, everything must be service to the user, can not serve the user's innovation is meaningless.

Of course, in addition to the cottage, alinq Dynamic also carried out a series of micro-innovation, but only one purpose, service users, to bring more convenience to users. These micro-innovations will be mentioned later.

Alinq Dynamic V1.5 This version, did a major update, fixed a large number of bugs, has implemented the function of entity SQL 95% (not supported, is a very unique method), while providing a full document of more than 40 pages, it is a milestone version, You must not be missed, folks.

: http://esql.codeplex.com/

Authorized

Alinq Dynamic is open source and uses the MIT licensing agreement. This is a very loose license, you know. I do not mind that we can build on this basis, a more excellent, excellent framework, whether free or commercial . Sincerely look forward to the emergence of more high-level work at home.

Introduction

Alinq Dynamic provides a entiy SQL query interface for ALINQ and LINQ to SQL, enabling them to apply entity SQL for data queries. Its rationale is to interpret entiy SQL as a LINQ expression and then execute the resulting LINQ expression.

Highlights

Alinq Dynamic has many bright spots in addition to the high imitation Entity Framework.

1. Seamlessly connect to LINQ expression. seamless interfacing with LINQ expression gives you a high degree of flexibility in writing ESQL statements. The advantages of static queries and dynamic queries can be well combined.

Example One

Use a parameterized data source. You can use a LINQ query to pass in an ESQL statement as a parameter.

var " EN " ); var " Select E from @0 as E where e.lastname! = ' Mak ' " ; var q = db. CreateQuery (esql, employees);

Example Two

Supports querying with indexers, which brings great convenience to weak types of queries.

var @" Select E.firstname, e.lastname from Employees as e " ; var q = db. Createquery<idatarecord>(eSQL)            . Where (o= (string) o["FirstName""Mike  ");

2. Support for interface-based queries

Basic support for interface queries, when used, has several benefits

1) provides a great use for code marshaling, such as you can entity classes, abstracting out a most basic interface, and then provide some common methods of invocation.

2) Entity classes can be generated dynamically without having to be generated at compile time. For example, you can generate entity classes at run time, and the benefit is that when you need to add a field to a table, you do not need to regenerate the entity. The new field can be used by the indexer.

3) makes it possible to apply an AOP-based injection.

Example

The following example is an interface-based query example, and it is worth noting that the Employee entity class inherits the iemployee interface.

var " Select E from Employees as E " ; var q = db. Createquery<iemployee>(eSQL)            "F""L"  )            new {o.firstname, o.lastname, o.birthdate});
Use

1. For alinq users, refer to Alinq.dynamic, and refer to System.Linq.Dynamic for Linq to SQL users. These two assemblies can be found in the binary folder in the downloaded compressed package.

2. In the code, import the Alinq.dynamic namespace.

The following is a complete example.

usingSystem;usingNorthwindDemo;usingalinq.dynamic;namespaceconsoleapplication1{classProgram {Static voidMain (string[] args) {            vardb =NewNorthwindDataContext (@"D:\esql\source\db\Northwind.db3"); varESQL ="Select p from Product as P"; varQ = db. Createquery<product>(ESQL); foreach(varIteminchq) Console.WriteLine (item.        ProductName); }    }}
About the ALINQ version

ALINQ Dynamic uses the latest free version of Alinq, if you're using a different version, you'll need to set it up in App. Config, or recompile your code. Please use the following example:

    <xmlns= "urn:schemas-microsoft-com:asm.v1">      < dependentassembly >        <  name= "System.Data.SQLite"  publickeytoken= "db937bc2d44ff139"  culture= "neutral"/>        <oldversion  = "1.0.0.0-1.0.66.0"  newversion= "1.0.61.0"/>      < /dependentassembly>    </assemblybinding> 

Reference page:

Http://www.yuanjiaocheng.net/CSharp/Csharp-do-while-loop.html

Http://www.yuanjiaocheng.net/webapi/web-api-reqresq-format.html

Http://www.yuanjiaocheng.net/Jsp/first.html

Http://www.yuanjiaocheng.net/webapi/config-webapi.html

Http://www.yuanjiaocheng.net/Entity/first.html

Http://www.yuanjiaocheng.net/mvc/create-layout-view-in-mvc.html

Http://www.yuanjiaocheng.net/webapi/create-crud-api-1-put.html

Http://www.yuanjiaocheng.net/Linq/linq-api.html

Http://www.yuanjiaocheng.net/webapi/mvc-consume-webapi-delete.html

Http://www.yuanjiaocheng.net/ASPNET-CORE/project-layout.html

Http://www.yuanjiaocheng.net/mvc/mvc-helper-htmlstring.html

High imitation entity Framework? Linq to SQL also has spring!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.