使用实体框架6中的工作单元和存储库模式调用存储过程。

编程入门 行业动态 更新时间:2024-10-28 08:19:31
本文介绍了使用实体框架6中的工作单元和存储库模式调用存储过程。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

向所有人致意 我正在使用工作单元,存储库模式与实体框架6(代码优先方法)以及依赖注入, 我已扩展我的存储库以执行以下存储过程 public List< tentity> ExecuteStoreProcedure(IUnitOfWork unitofWork,string spName,params object [] parameters) { return((DataContext)unitofWork.getDBContext())。Database.SqlQuery< tentity>( spName,parameters)。ToList(); } 我的问题是。 1.如何使用这种设计模式调用我的调用我的存储过程(我正在做的是正确的)。 2.如何让实体框架生成类来保存来自我的存储过程的数据(< tentity>)。 a)我有很多存储过程,我不想为所有这些创建POCO类。

Greetings to all I am using unit of work, repository pattern with entity framework 6 (code first approach) along with dependency injection, I have extended my repository to execute stored procedures as below public List<tentity> ExecuteStoreProcedure(IUnitOfWork unitofWork, string spName, params object[] parameters) { return ((DataContext)unitofWork.getDBContext()).Database.SqlQuery<tentity>(spName, parameters).ToList(); } my questions are. 1.How can I call my call my stored procedures using this design pattern(is what I am doing is correct). 2.How can I make entity framework generate classes to hold the data from my stored procedures on the fly(<tentity>). a) I have lots of stored procedures and I do not want to create POCO classes for all of them.

推荐答案

你好Vailbhav Nigam。 如果你免费那么你可以查看以下链接 www.remondo/repository -pattern-example-csharp / [ ^ ] Hi Vailbhav Nigam. If u r Free then u can checkout the below link www.remondo/repository-pattern-example-csharp/[^]

更多推荐

使用实体框架6中的工作单元和存储库模式调用存储过程。

本文发布于:2023-11-06 22:18:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564822.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存储过程   实体   框架   模式   工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!