EF 4.1 代码优先原始 SQL
我想使用 RAW SQL 返回实体,因此我有以下代码返回一组实体:
var rawSql = "exec spFindStories @pattern, @page, @pageSize";
// use raw SQL because SP is needed
// results are not tracked.
var stories = context.Database.SqlQuery<Story>(rawSql,
new SqlParameter("@pattern", pattern),
new SqlParameter("@page", page),
new SqlParameter("@pageSize", pageSize)
).ToList();
现在,对于每个故事,我需要加载其相关标签。看来CF没有加载结果中返回的相关实体。我怎样才能做到这一点?
谢谢!!
I would like to return entities using RAW SQL, so I have the following code which returns a set of Entities:
var rawSql = "exec spFindStories @pattern, @page, @pageSize";
// use raw SQL because SP is needed
// results are not tracked.
var stories = context.Database.SqlQuery<Story>(rawSql,
new SqlParameter("@pattern", pattern),
new SqlParameter("@page", page),
new SqlParameter("@pageSize", pageSize)
).ToList();
Now for each one of these stories, I need to load their related Tags. It seems that CF does not load related entities returned in the results. How can I achieve this ??
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不将其添加为函数导入并指定它返回的内容作为您期望的实体?
Why not add it as a function import and specify what it's returning as the entity you expect?