您当前的位置: 首页 > 

暂无认证

  • 0浏览

    0关注

    100382博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

[EF]使用参数

发布时间:2019-06-12 14:24:47 ,浏览量:0

using (var context = new KTStoreContext())
            {
               // object[] parameters = { 8, "%移动%" };


                SqlParameter P0 = new SqlParameter("P0", 8);
                SqlParameter P1 = new SqlParameter("P1", "%移动%");
                SqlParameter[] parameters = { P1, P0 };

                String sql = 
                    "SELECT Id,Name,Price FROM Product WHERE Id > @P0 AND Name LIKE @P1";
                DbRawSqlQueryquery = 
                    context.Database.SqlQuery(sql,parameters);
                Listproducts = query.ToList();
                foreach (SProduct product in products)
                {
                    Console.WriteLine("{0}\t{1}\t售价:{2} 元",
                        product.Id, product.Name, product.Price);
                }
            }
            Console.ReadKey();
关注
打赏
1655516835
查看更多评论
立即登录/注册

微信扫码登录

0.0731s