Skip to content

Instantly share code, notes, and snippets.

@SergiyOsadchyy
Created July 24, 2018 10:55
Show Gist options
  • Select an option

  • Save SergiyOsadchyy/71f16f3f2d777590bd854e371fd9efc1 to your computer and use it in GitHub Desktop.

Select an option

Save SergiyOsadchyy/71f16f3f2d777590bd854e371fd9efc1 to your computer and use it in GitHub Desktop.
test_delete
using System.Collections.Generic;
using Domain;
using System;
using System.Data.SqlClient;
namespace Persistence
{
public class SqlBusinessTree: IRepository
{
SqlConnection conn;
SqlCommand comm;
SqlDataReader dreader;
/* ToDo: define connection string */
string connstring = "our connection string";
public UnbindedData GetData(long id)
{
return null;
}
public void UpdateLevel(Level item, long? firstLevel = null)
{
throw new System.NotImplementedException();
}
public void UpdateProperty(Property item, long? firstLevel = null)
{
throw new System.NotImplementedException();
}
public void Delete(long id)
{
conn = new SqlConnection(connstring);
conn.Open();
comm = new SqlCommand("delete from Levels where Levels.LevelID = " + id + " ", conn);
try
{
comm.ExecuteNonQuery();
Console.Writeline("Deleted...");
}
catch (Exception x)
{
Console.Writeline(" Not Deleted" + x.Message );
}
finally
{
conn.Close();
}
/* ToDo: придумать что делать с висящими ветками */
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment