心雨纷扬

 

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;

 

posted on 2017-02-07 09:22  心雨纷扬  阅读(265)  评论(0编辑  收藏  举报

导航