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;

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)
    {
      List<MyObject> items = new List<MyObject>();
      for (int i = 0; i < 10; i++) //create ten objects
        items.Add(new MyObject() { Name = Guid.NewGuid().ToString() });

      _dstore.InsertObjects(items);

      //each object will have the id set when its done so..
      items.ForEach(R => _dstore.DeleteObject(R)); //lets clean up
    }
  }
}

Last edited May 30, 2013 at 3:22 AM by iamkrillin, version 5

Comments

No comments yet.