This technique can be particularly useful if you need to pull a large set of data from the data store, do some sort of calculation on it and store the result back into the data store for fast retrieval later.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using DataAccess.Core;
using DataAccess.SqlServer;
using DataAccess.Core.Interfaces;
using System.Diagnostics;
using System.Data.SqlClient;

namespace SauceExample
  public class CrudClass
    public static IDataStore _dstore; //I recommend keeping the reference around

    static CrudClass()
      _dstore = SqlServerConnection.GetDataStore(ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString);

    public static void Main(string[] args)
      Stopwatch watch = new Stopwatch();

      Type mType = typeof(MyObject);
      SqlCommand cmd = new SqlCommand();
      cmd.CommandText = string.Format("SELECT id FROM {1}", _dstore.GetSelectList(mType), _dstore.GetTableName(mType));

      List<MyObject> objects = _dstore.ExecuteCommandLoadList<MyObject>(cmd);


Last edited May 30, 2013 at 3:20 AM by iamkrillin, version 2


No comments yet.