This question already has an answer here:
- Return Anonymous Type from a function 5 answers
I have been googling this question for a while. With that said, it seems that I keep getting the same answer, not the answer I am looking for. So I thought I would ask here. What I would like to do is create an anonymousType and pass it in to a method for that method to use like a strongly typed class.
How can I do this?
var desiredAnonymousTypes = new
{
Column1Name = ColumnTypeHere,
Column2Name = ColumnTypeHere,
Column3Name = ColumnTypeHere
};
SqlParameter[] @params =
{
new SqlParameter("UserName","Jon Doe")
};
var list = CastExample.RunStoredProcdure<desiredAnonymousTypes>("GetContactsByUser", @params);
public static IEnumerable<T> RunStoredProcdure<T>(string sprocName, SqlParameter[] @prams)
{
var list = new List<T>();
//run sproc already works
return list;
}
Aucun commentaire:
Enregistrer un commentaire