[英]Entity Framework linq to stored procedures
I using plain LINQ to query my database in my MVC web application. 我使用普通LINQ在MVC Web应用程序中查询数据库。 I have queries similar to this one 我有与此类似的查询
list = context.Courses.Join(
context.Departments,
course => course.DepartmentId,
department => department.ID,
(course, department) => new { course, department })
.Select(f => new FriendlyCourseViewModel
{
ID = f.course.ID,
Acronym = f.department.Acronym,
CourseNumber = f.course.CourseNumber,
CourseName = f.course.CourseName
});
where context is my dbcontext class. 上下文是我的dbcontext类。 I'd like certain LINQ queries to use sanitized input. 我希望某些LINQ查询使用经过清理的输入。 Should I be making all of my LINQ queries into SP (stored procedures) to sanitize my input? 我是否应该将所有LINQ查询都放入SP(存储过程)中以清理输入? If yes, is there an easy way I can convert my LINQ to a SP? 如果是,是否可以将LINQ转换为SP的简便方法?
Are you talking about using paramerterized queries? 您是在谈论使用准参数化查询吗? If so, Entity Framework is already doing that. 如果是这样,那么实体框架已经在这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.