简体   繁体   English

数据访问层-亚音速,C#2.0

[英]data access layer - subsonic, C# 2.0

digging around subsonic, i came across this 在亚音速周围挖洞,我遇到了这个

link text 连结文字

good article but have some ?'s 好文章,但有一些?

now i want the option to return either a IList or Dataset, would I create an abstarct factory for this, if so can I have one generic method which would take in either IList or Dataset as a ref parameter and populate the passed in object? 现在我想选择返回IList或Dataset的选项,是否可以为此创建一个abstarct工厂,如果可以的话,是否可以有一个通用方法将IList或Dataset用作ref参数并填充传入的对象?

is it a good practice to declare static classes in the business layer which talks to my data layer so that in my UI where i have a gridviewcontrol i can do this 在与我的数据层对话的业务层中声明静态类是一个好习惯吗,以便在我有gridviewcontrol的UI中可以执行此操作

mybusinesslayer.getdata(ref myDataset) //as mybusinesslayer is static mybusinesslayer.getdata(ref myDataset)//由于mybusinesslayer是静态的

mygridviewcontrol.datasource = mydataset.... mygridviewcontrol.datasource = mydataset ....

What are you planning to do with the Datasets that you cannot do with the ILists? 您打算如何处理ILists无法处理的数据集? IMHO, you'll want to be strongly typed as much as possible. 恕我直言,您将需要尽可能强地键入。

On my team, we connect our middle tier to ObjectDataSources and then all of our GridViews, ListViews, etc... use them to fetch data: 在我的团队中,我们将中间层连接到ObjectDataSources,然后所有的GridView,ListView等...使用它们来获取数据:

Business Layer / Middle Tier 业务层/中间层

namespace Project
{
    public class BusinessLayer
    {
        public IList<Product> GetProducts()
        {
            return new Select().From( Products.Schema ).Where( Products.Columns.Status ).IsEqualTo( true ).ExecuteTypedList<Product>();
        }
    }
}

On Page 在页面上

<asp:ObjectDataSource id="odsProducts" runat="server" TypeName="Project.BusinessLayer" SelectMethod="GetProducts()"></asp:ObjectDataSource>

Then from there, you can connect any of your data-view controls (Gridview, Listview, etc...) to the data source. 然后从那里,您可以将任何数据视图控件(Gridview,Listview等)连接到数据源。 It's very clean and requires no code in the code-behind. 它非常干净,并且不需要任何代码。

I also came across that article by Rob that you posted and have found it helpful in trying to figure out how to write de-coupled apps with SubSonic. 我还看到了您发布的Rob的文章,发现它有助于尝试弄清楚如何使用SubSonic编写解耦的应用程序。

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

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