我是EF的新手。 试图获取内联查询的一些记录..
我跟着 http://geekswithblogs.net/rgupta/archive/2010/06/23/entity-framework-v4-ndash-tips-and-tricks.aspx
有dode
var lstStatInfo = new List<BISRCNCCYC>();
using (var contextobj = new TADBEntities(_connStr, _scheName))
{
string sql = "select * from MYTABLE where MYID = :MYID";
int id = 475;
var args = new DbParameter[] { new OracleParameter { ParameterName = "MYID", Value = "475" } };
var students = contextobj.Database.ExecuteSqlCommand(sql, id);
return lstStatInfo;
}
甚至尝试过 How to pass parameters to the DbContext.Database.ExecuteSqlCommand method?
但是收到错误ORA-00936:表达式缺失
我正在尝试连接oracle而不是SQl ......应该是什么样的正确方法?
答案 0 :(得分:0)
改变你的
string sql = "select * from MYTABLE where MYID = {0}";
要
string sql = "select * from MYTABLE where MYID = :MYID";