本文介绍了SubSonic 和存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 SubSonic 时,您是将数据作为数据集返回,还是将其放入强类型自定义集合或通用对象中?

When using SubSonic, do you return the data as a dataset or do you put that in a strongly typed custom collection or a generic object?

我运行了 subsonic 项目,对于我数据库中的四个存储过程,它给了我一个 Sps.cs,其中包含 4 个返回 StoredProcedure 对象的方法.

I ran through the subsonic project and for the four stored procs I have in my DB, it gave me a Sps.cs with 4 methods which return a StoredProcedure object.

如果您使用 MVC,您通常使用 StoredProcedure 对象还是将其包装在您的业务逻辑周围并返回数据集、列表、集合或其他内容?

If you used a MVC, do you usually use the StoredProcedure object or wrap that around your business logic and return a dataset, list, collection or something else?

数据集仍然是常态还是被其他东西取代?

Are datasets still the norm or is that replaced by something else?

推荐答案

如果存储过程的结果与您的表具有相同的架构,您可以使用此代码(SubSonic 2.1)构建一个集合:

If the results of the stored procedure has the same schema as one of your tables, you can build a collection using this code (SubSonic 2.1):

ProductCollection coll = new ProductCollection();
coll.LoadAndCloseReader(SPs.GetProducts(1).GetReader());

这篇关于SubSonic 和存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 13:23