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);
    }

    [STAThread]
    public static void Main(string[] args)
    {
      Stopwatch watch = new Stopwatch();
      watch.Start();

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

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

      watch.Stop();
    }
  }
}

Last edited May 30, 2013 at 4:19 AM by iamkrillin, version 2

Comments

No comments yet.