EF.Mysql在codefirst模式下调用存储过程,和再DbFirst模式下的调用
List<GetUserUpCrmList_Result> r = null; using (var context = new HimallContext()) { var parameter = new MySqlParameter("@uid", MySqlDbType.Int64) {Value = uid}; r = context.Database.SqlQuery<GetUserUpCrmList_Result>("call GetUserUpCrmList(@uid)", parameter).ToList(); } return r;
public virtual ObjectResult<GetUserUpCrmList_Result> GetUserUpCrmList(string uid) { var uidParameter = uid != null ? new ObjectParameter("uid", uid) : new ObjectParameter("uid", typeof(string)); return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetUserUpCrmList_Result>("GetUserUpCrmList", uidParameter); }
sqlserver 的codefirst调用
List<GetUserUpCrmList_Result> r = null; using (var context = new HimallContext()) { var parameter = new SqlParameter("@uid", SqlDbType.Int64) {Value = uid}; r = context.Database.SqlQuery<GetUserUpCrmList_Result>(" GetUserUpCrmList @uid", parameter).ToList(); } return r;