/
SqlInsertCommandBuilder.cs
49 lines (43 loc) · 1.71 KB
/
SqlInsertCommandBuilder.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
using System.Collections.Generic;
using System.Linq;
using Paradigm.ORM.Data.CommandBuilders;
using Paradigm.ORM.Data.Database;
using Paradigm.ORM.Data.Descriptors;
namespace Paradigm.ORM.Data.SqlServer.CommandBuilders
{
/// <summary>
/// Provides an implementation for sql insert command builder objects.
/// </summary>
/// <seealso cref="CommandBuilderBase" />
/// <seealso cref="IInsertCommandBuilder" />
public class SqlInsertCommandBuilder : InsertCommandBuilderBase, IInsertCommandBuilder
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="SqlInsertCommandBuilder"/> class.
/// </summary>
/// <param name="connector">A database connector.</param>
/// <param name="descriptor">A table type descriptor.</param>
public SqlInsertCommandBuilder(IDatabaseConnector connector, ITableDescriptor descriptor): base(connector, descriptor)
{
}
#endregion
#region Protected Methods
/// <summary>
/// Gets a list of column descriptors that must be used in the insert statement.
/// </summary>
/// <returns>
/// A list of column descriptors.
/// </returns>
/// <remarks>
/// Some databases may impose restrictions or limitation to the columns that can be
/// inserted due to type or other rules. For ejample, TIMESTAMP type in sql server
/// can not be inserted nor updated.
/// </remarks>
protected override List<IColumnDescriptor> GetInsertColumns()
{
return this.Descriptor.SimpleColumns.Where(x => x.DataType.ToLower() != "timestamp").ToList();
}
#endregion
}
}