Regarding the new version of Microsoft Enterprise Libarary 6 , they have a method called ExecuteSprocAccessor
(which should return Ienumerable<T>
when execute SP) which all its overload are :
Usage example :
/*1*/ [Description("Return data as a sequence of objects using a stored procedure")]
/*2*/ static void ReadDataAsObjects()
/*3*/ {
/*4*/ // Create an object array and populate it with the required parameter values
/*5*/ object[] paramArray = new object[] { "%bike%" };
/*6*/ // Create and execute a sproc accessor that uses default parameter and outpu`t mappings
/*7*/ IEnumerable<Product> productData = defaultDB.ExecuteSprocAccessor<Product>("GetProductList", paramArray);
/*8*/ //...
/*9*/ //...
/*10*/ }
Additional Info :
The parameter adding mechanism (here) is very problematic because there is no ParameterName to value
association.
all they do there is (at line 5)
object[] paramArray = new object[] { "%bike%" };
So I guess If I have more then 1 param it will look like :
object[] paramArray = new object[] { "%bike%",19,"lala"... };
which means that I'll have to know the order of sp's param input order !!!
NB
Other methods do have this sort of attaching values to name :
defaultDB.AddInParameter(sprocCmd, "state", DbType.String, "New York");
Question
Is there any way of using ExecuteSprocAccessor
and still do ParameterName to value
association ? (assuming I don't know the sp input param order ?