Using Entity Framework and a Storage Procedure with Parameters
So I was stuck sometime ago on a problem I had where I was using my sql store procedure with the Entity Framework. Eventually found what I needed and the purpose of this article is just to write out a small example. I've come up with multiple ways to achieve the same thing now but this is the most basic form of it.
public IList<KeyValuePair> GetIds(string id) { using (var db = DBFactory.GetDB()) { return db.Database.SqlQuery<KeyValuePair>( "EXEC db.MyDatabase @id", new SqlParameter("id", id)); } }
Resources