-
Notifications
You must be signed in to change notification settings - Fork 2
/
FileMakerDelete.cs
68 lines (54 loc) · 1.93 KB
/
FileMakerDelete.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FileMakerConnect
{
public class FileMakerDelete : FileMakerCommand
{
#region Properties
public string DeleteClause { get; set; }
#endregion
#region Constructors
public FileMakerDelete(string connectionString) : base(connectionString) { }
public FileMakerDelete(FileMakerConnect connect) : base(connect) { }
public FileMakerDelete(string connectionString, string tableName) : base(connectionString)
{
DeleteClause = String.Format("DELETE FROM \"{0}\"", tableName);
}
public FileMakerDelete(FileMakerConnect connect, string tableName) : base(connect)
{
DeleteClause = String.Format("DELETE FROM \"{0}\"", tableName);
}
#endregion
#region Methods
public void DeleteFrom(string tableName)
{
DeleteClause = String.Format("DELETE FROM \"{0}\"", tableName);
}
public override string BuildOutputString()
{
if (String.IsNullOrEmpty(WhereClause))
throw new InvalidDeleteException("Unable to delete without a WHERE clause");
if (String.IsNullOrEmpty(DeleteClause))
throw new InvalidDeleteException("Unable to delete without DELETE FROM clause");
string result = DeleteClause + " ";
if (!String.IsNullOrEmpty(FromClause))
result += FromClause + " ";
result += WhereClause;
return result;
}
public override void Clear()
{
DeleteClause = null;
FromClause = null;
WhereClause = null;
}
#endregion
}
public class InvalidDeleteException : Exception
{
public InvalidDeleteException() { }
public InvalidDeleteException(string message) : base(message) { }
}
}