單一資料表操作
var result = _todoContext.TodoLists.FromSqlRaw("select * from todolist");
[HttpGet("GetSQL")] public IEnumerable<TodoList> GetSQL(string name) { string sql = "select * from todolist where 1=1"; if (!string.IsNullOrWhiteSpace(name)) { sql = sql + "and name like N'%" + name + "%'"; } var result = _todoContext.TodoLists.FromSqlRaw(sql); return result; }
參考資料
0 意見:
張貼留言