Reputation: 5233
My MVC application accesses DB2/400.
My DAL dll is being build around ADO.NET.
I need to build some simple controller actions. I dont want to go all over execute datareader methods just to get something simple and make my DAL fat.
These actions are mostly generic SQL Statements that fix some bugs in our enterprise systems, so i want to keep them simple and to alter them easy.
Is it ok if i use the webmatrix.data db api as i am using it in Web Pages ?
If not is there any simple alternative to that?
Upvotes: 0
Views: 364
Reputation: 5233
I finally chose DAPER as my solution
It does exactly what i want. Extends IDBconnection and gives me what i need.
Example:
The equivalent in plain ado.net method would be 20-30 lines in order to execute the datareader and iterating through the results.
This is Dapper implementation:
private IDbConnection db = new OleDbConnection(ConfigurationManager.ConnectionStrings["ENTERBG"].ConnectionString);
ViewBag.F4211 = this.db.Query<dynamic>(@"SELECT sdivd,SDDOC,SDDCT,SDDOCO,SDDCTO,SDODOC,SDODCT FROM F4211 WHERE SDDCT IN
('E8','E9','E0','EP','EC','EB','ED') AND SDODOC <> SDDOC AND
SDODOC<>0 order by sdivd");
The above example serves as an EXAMPLE. I am NOT gonna use the ViewBag for this.
Upvotes: 0
Reputation: 30075
You can use WebMatrix.Data if you like, but you could also look at Massive (https://github.com/robconery/massive) which was inspired by WebMatrix.Data. It might be more in keeping with an enterprise-style approach.
Upvotes: 1