Another great article by Rob on the Massive ORM. What I haven't been able to find is references on how to access stored procedures. SubSonic had some issues with the overhead of using ActiveRecords, so I preferred to do data access with stored procedures, still using the SubSonic ORM.
What I haven't yet seen is outright support for things like SQL Server's TVP's in an ORM, so I modified SubSonic (shameless plug) to support them.
Is it possible to access SQL Server sprocs with Massive. Secondly, is there TVP support?
Stored procedures are not specially supported, but because you can execute basically any SQL with Massive they will just work:
Sample from the Massive Update 2 article:
var orders = tbl.Query("CustOrdersOrders #0", "ALFKI");
foreach (var item in orders) {
Console.WriteLine(item.OrderID);
}
And if your main focus is on stored procedures there is even a Micro ORM comparison article about it: MicroORMs for .NET: Stored Procedures
Related
We are at the beginning to build up our site. Maybe you should check it out first to understand our problem: www.erasmusinn.com
Basically we are thinking about to use MySQL for stored procedures or not.
We only need to insert and update our database. Since we are planning to have thousands of database entities, it is very important that we use the most efficient way to update our database.
What do you think? Should we use MySQL?
Personally i would recommend PostgreSQL. It's free to use and easy to migrate from MySQL, and you can build your own functions, views, and have data relations.
We have a large database and we do manipulations on it ever day by using the basic mysql queries.
Can anyone please tell me, what is the use of Mysql Stored Procedures?
The real use of the Stored Procedures comes into picture when have any application accessing database.
For example: Imagine that you have written all your database operations in the form of queries in your data access code.
Suppose, that you need to make any change to query , then you need to rebuild and redeploy the entire application in order see your changes.
But, if you are using stored procs and refering them in application, you can just make changes in your database with out need for redeploying the application.
So, obviously better security , maintainability and much more
Note: This is one scenario where stored procs are better than normal queries.
Usage of Stored Procs also avoids SQL Injection Attacks
In very simple words, stored procedures allow you to store your quires along with database, you can combine multiple quires in single procedure. now whenever you want to execute those quires just "CALL yourProcedure;"
Need to perform specific query daily ?
Read about MySQL events = stored procedures with scheduling capability !
https://dev.mysql.com/doc/refman/5.1/en/events.html
I am trying to work with EF, for the first time ever. I'm not sure I fully understand EF yet.
I already have a database with data in it, so I've generated my models from DB.
Our current setup runs EVERYTHING through stored procedures, even selects.
However, unless I'm mistaking, the models select directly into the tables, when I have generated them.
Can I change this behaviour, so it calls the select procedure instead?
No - at least with EF4. I can't speak for EF5
You can use stored procedures to insert and update, but those stored procedures must have all the parameters EF expects, so you're probably going to have to wrap your existing procedures in new procedures.
For select, you can use a FunctionImport and ExecuteFunction to populate an Entity.
I need to import data from several tables in one database to corr tables in another database.
I tried doing this using multiple cursors within a stored procedure. One cursor for each table.
However, I find it difficult to troubleshoot any errors.
Can anyone suggest some alternate methods to create this type of stored procedure or a way to debug the errors.
Yes, use SSIS.
It was designed to handles these kinds of ETL Scenarios.
What's the proper way of importing/declaring stored procedure in Hibernate.
Currently,in my setup, Hibernate is configured to generate the schema if it doesn't exists, and I have import.sql file to insert referential data.
Should I include the source of the procedure into the import.sql file, or there's a better way to do so ?
It is not a good practice to use the hibernate to generate the table. There should be separate scripts created for that. Basically hbm2ddl.auto=create setting in hibernate is a temporary way to create the tables, but you should not be using it in a standard application. It is even unsafe to have this entry in your configuration settings.Read here for more.
If you have a import.sql that can generate the shcema and the other DB entities run it independent of the application. It is always best, not to mix up creating the DB entities (including stored procedures and tables) and using them.
There is none. Stored procedures are out of scope of hibernate. At most you can issue native SQL query , but it will bypass everything. Usually you just take sql script generated by schema export and enhance it manually