简体   繁体   English

C#ASP.NET中的动态业务对象

[英]Dynamic Business Objects in C# ASP.NET

I have ac# application where I am reading individual columns of stored procedure results into output class objects. 我有一个ac#应用程序,在其中将存储过程结果的各个列读取到输出类对象中。 However if the number of columns in the stored procedure changes, i have to rewrite the data access layer code. 但是,如果存储过程中的列数发生了变化,我必须重写数据访问层代码。

Is there any way where changing the number of columns in the output stored procedure doesn't make me change the code in the data access layer? 有什么办法可以改变输出存储过程中的列数,而不会使我改变数据访问层中的代码? I am a beginner. 我是初学者。

There are ORM tools that can automatically generate data access layer code for you. 有一些ORM工具可以自动为您生成数据访问层代码。 In the case of .NET, there is the Entity Framework. 对于.NET,有实体框架。

http://msdn.microsoft.com/en-us/data/ef.aspx http://msdn.microsoft.com/en-us/data/ef.aspx

如果您要更改返回数据的结构,并且您依赖于该结构,则无论您自己进行映射,使用ORM还是依赖简单的DataTable作为容器,都将始终导致代码更改。

I personally believe that, Data-First model in EF may work in this scenario. 我个人认为,EF中的“数据优先”模型可能会在这种情况下起作用。 Also was going through ExpandoObjects in c# 4.5. 也正在通过C#4.5中的ExpandoObjects。 Maybe this can work too. 也许这也可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM