Which ORM will give me programmed queries?

Which ORM will provide me with the programmed queries?

Checked linqtosql compile time?


Edit:

Let's say I'm writing a query that refers to a column called "TotalSales". Then I will rename the column in my database to TotalSales2 (and any other configuration file, for example: Employee.cfg.xml in nHibernate).
When I compile the project, I want Visual Studio to tell me that the column "totalSales" does not exist, and then I go and change it.

+4
source share
7 answers

No, as far as I know. They often allow you to create a LINQ query that cannot be converted to SQL, for example. Also, I don't know what compilation time checks if your mappings are displayed correctly in your database.

You can and should, in my opinion, perform all of these tests as part of the tests. Most ORMs make this easy.

+5
source

I use LLBLGen , but it should be β€œupdated” when data model changes are made. I don't think you will get an ORM that will check the COMPILE TIME time for changes to the database. You ask there a little.

+2
source

In the DataObjects.Net properties marked with the [Field] attribute, they are always bound to a field in the database, so you can be sure that the request will be translated. If you use a non-constant field or another unsupported operator, the query translator will not work at run time or will perform such an operation with selected objects (on the client).

Usually checking compilation time is not possible or theoretically can be performed using special post-build tasks that will scan the compiled code, find all the requests and check them. But such checks seriously slow down the compilation process.

+1
source

It may not be exactly what you are looking for, but when using the Entity Framework and selecting "Update Model from Database" from the designer, you will receive messages that the fields no longer appear if you change the names.

This does not happen automatically when creating a project.

+1
source

Basically, you need two functions together:

  • Requests with validation at compile time (= ORM with LINQ implementation). This is usually not a problem - at least some tools support this.
  • A pre-build step that updates your objects based on the database schema. AFAIK this is rarely implemented this way - usually you should explicitly update the model according to the scheme. Please note that this part is usually quite expensive.
+1
source

SubSonic can do this if you enable the code generation step as a pre-build event.

0
source

I used a Java tool called DODS, which was developed by ca. 2000 with the Enhydra application server. DODS is still here: http://www.enhydra.org/tech/dods/

How DODS works, and which matches your purpose of checking compile time, is that it is a code generation tool. It generates Java classes matching the tables in your database. The object instances of these classes have getters and seters for each column in the table. Of course, if you change the structure of your database, you will have to regenerate the Java code using DODS.

As long as you keep the generated code up-to-date with the structure of your database, it provides compile-time checks that any application code that uses these classes requests valid tables and columns.

In any case, I understand that you have noted your question in C # and ASP.NET. The tool that generates Java code will not be so useful to you. But for .NET, there may be another tool that works on the same principle of code generation, which maps to the database structure. Therefore, I would suggest narrowing your search to .NET ORM tools that say something about code generation.

0
source

All Articles