Getting Started with SEAM.Data

Aug 28, 2009 at 10:06 PM
Edited Aug 31, 2009 at 3:34 AM

Since SEAM Library is intended to be a framework rather than a specific implementation, there are certain steps that you need to get started with SEAM.  Below is a quick "start up" guide to implementing SEAM DAL in your environment.

Step 1 - Create a DataAccessProvider

Creating a DataAccessProvider involves writing a class that implements SEAM.Data.Provider.IConnectionProvider.  This class will be responsible for providing concrete connections to your data sources.  Sample code below gives you a very simple example, refer to discussion topic DataAccessProvider Explained for detailed explanation of DataAccessProviders:

using System;
using SEAM.Data;
using SEAM.Data.Provider;
using SEAM.Data.SqlServer;

// Use a namespace that follows your organization's architecture directions
namespace ABCInc.Data
    class SimpleProvider : IConnectionProvider
        public DataAccess GetDataAccess(params object[] args)
            // Always returns a Sql Server connection 
// to Northwind database on localhost
return new SqlDataAccess("Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True"); } } }

Step 2 - Modify your application's config file

Now that you have created your own DataAccessProvider (SimpleProvider), SEAM's DAL must be configured to utilize your SimpleProvider to provide concrete connections to the application.  The simplest way of doing this is to modify your application's configuration file (e.g. web.config).

    <sectionGroup name="SEAM">
      <sectionGroup name="data">
          type="SEAM.Data.Provider.ConnectionProviderHandler, SEAM.Data, Version=, Culture=neutral, PublicKeyToken=null"
      <!-- Initilizes ConnectionProvider for this application -->
<!-- We assume that the DataAccessProvider is compiled in ABCInc.Data.dll -->
<connectionProvider name="simpleProvider" type="ABCInc.Data.SimpleProvider, ABCInc.Data, Version=, Culture=neutral, PublicKeyToken=null" /> </data> </SEAM> </configuration>

Step 3 - Utilize SEAM's DAL in your application.

To use SEAM's DAL, the developers should interact with SEAM.Data.DataAccess class to interact with the database.  Below are few examples of how to interact with the database: 

// Execute an inline query and save it to a DataTable
DataTable dtCustomers = DataAccess.ExecuteQuery("SELECT * FROM Customers");

You can utilize methods provided in DataAccess class to execute other types of transactions such as execute stored procedures, execute non-scalar sql statement, etc.  You can also utilize methods provided to directly bind results directly to objects.  Other examples on usage will be posted soon.  Until then refer to SEAM.Test.Data project for examples.