c# - Executing SQL queries in a Controller Action -


i have 5 separate sql queries executing in order in controller action. method using execute them:

var entity = new testentities();  entity.database.executesqlcommand("//sql query"); 

so, have 5 executesqlcommand in row different queries must execute in order , code must continue execute below them. there better way execute queries inside controller action? not sure best way error handling current method.

thanks!

to start @ creating abstraction layer in between controller , database. example of repository, when come testing. can create mock repositories can use in unit tests rather testing against actual database.

you mention have 5 different database commands fire. @ unit of work pattern can use track have changed , apply of these changes database.

there article on microsoft's asp.net website implementing repository , unit of work.

using repository , unit of work


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -