Upgrading from webforms, how can I accomplish this in MVC using Dapper?
I have an old webforms site that it just reading data from couple of databases. I have many queries and a function the the gets the DB data.
I have this function that returns a datatable with the data based on passed query and parameteres.
public static DataTable ExeConnectds(string command_text, string connstring, params OracleParameter[] parameters) { DataTable tmp = new DataTable(); using (var ORAconnection = new OracleConnection(ConfigurationManager.ConnectionStrings(connstring).ConnectionString)) { using (var ORAcommand = new OracleCommand(command_text, ORAconnection)) { if (parameters != null && parameters.Length > 0) { foreach (var p in parameters) ORAcommand.Parameters.Add(p.ParameterName, p.OracleDbType, p.Size).Value = p.Value; } ORAcommand.Connection = ORAconnection; ORAconnection.Open(); tmp.Load(ORAcommand.ExecuteReader()); } } return tmp;
}'
Basically I can call this function from any page.
I've been working with Dapper and MVC and looks like I need to create a model/type for each query?
is there a way with dapper to create generic queries and pass generic parameters like in the webforms example above?
0 comments:
Post a Comment