This example wont execute has I have no other data source set up right now, however, the technique stands.

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)
    {
      List<MyObject> toMerge = GetItems();
      foreach (MyObject mo in toMerge)
      {
        if (_dstore.IsNew(mo))
          _dstore.UpdateObject(mo);
        else
          _dstore.InsertObject(mo);
      }
    }

    private static List<MyObject> GetItems()
    {
      throw new NotImplementedException();
    }
  }
}

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

Comments

No comments yet.