├── SharpData
├── Filters
│ ├── LogicOperator.cs
│ ├── FilterParameterType.cs
│ ├── FilterLogic.cs
│ ├── FilterCondition.cs
│ ├── CompareOperator.cs
│ ├── LogicOperatorToSymbol.cs
│ ├── FilterParameter.cs
│ ├── CompareOperatorToSymbol.cs
│ └── Filter.cs
├── Schema
│ ├── OrderByDirection.cs
│ ├── OnDelete.cs
│ ├── Table.cs
│ ├── OrderBy.cs
│ ├── FluentColumn.cs
│ └── Column.cs
├── Fluent
│ ├── IRemoveFromTable.cs
│ ├── IFluentRename.cs
│ ├── RemoveTable.cs
│ ├── RemoveColumn.cs
│ ├── ReversableFluentActions.cs
│ ├── RemoveItem.cs
│ ├── Count.cs
│ ├── RemovePrimaryKey.cs
│ ├── RemoveForeignKey.cs
│ ├── RemoveIndexKey.cs
│ ├── Delete.cs
│ ├── IFluentModify.cs
│ ├── IFluentAdd.cs
│ ├── Update.cs
│ ├── RemoveUniqueKey.cs
│ ├── AddIndexKey.cs
│ ├── Select.cs
│ ├── DataClientAddIndexKey.cs
│ ├── FluentRename.cs
│ ├── Insert.cs
│ ├── ModifyColumn.cs
│ ├── RenameTable.cs
│ ├── FluentCount.cs
│ ├── FluentDelete.cs
│ ├── AddColumn.cs
│ ├── AddTable.cs
│ ├── DataClientAction.cs
│ ├── RenameColumn.cs
│ ├── FluentScalar.cs
│ ├── RemoveComment.cs
│ ├── AddUniqueKey.cs
│ ├── AddPrimaryKey.cs
│ ├── FluentRemove.cs
│ ├── FluentUpdate.cs
│ ├── AddComment.cs
│ ├── FluentAdd.cs
│ ├── FluentSelect.cs
│ ├── FluentInsert.cs
│ └── AddForeignKey.cs
├── Databases
│ ├── DatabaseKind.cs
│ ├── MySql
│ │ ├── MySqlDataClient.cs
│ │ ├── MySqlDbFactory.cs
│ │ └── MySqlProvider.cs
│ ├── IDbTypeMap.cs
│ ├── Oracle
│ │ ├── OracleDataClient.cs
│ │ ├── OracleOdpDbFactory.cs
│ │ ├── OracleReflectionCache.cs
│ │ ├── OracleManagedProvider.cs
│ │ └── OracleManagedDbFactory.cs
│ ├── PostgreSql
│ │ ├── PostgreSqlDataClient.cs
│ │ ├── SqlColumnStructure.cs
│ │ ├── PostgreDbFactory.cs
│ │ ├── PostgreSqlProvider.cs
│ │ ├── PostgreSqlConstraintsDialect.cs
│ │ ├── PostgreSqlDbTypesDialect.cs
│ │ └── PostgreSqlTableDialect.cs
│ ├── SqLite
│ │ ├── SqLiteDataClient.cs
│ │ ├── SQLiteProvider.cs
│ │ └── SqLiteDbFactory.cs
│ ├── SqlServer
│ │ ├── OleDbDbFactory.cs
│ │ ├── SqlServerDataClient.cs
│ │ ├── SqlServerDbFactory.cs
│ │ └── SqlProvider.cs
│ ├── DataProvider.cs
│ ├── SelectBuilder.cs
│ ├── DbProviderType.cs
│ └── WhereBuilder.cs
├── Exceptions
│ ├── ProviderNotFoundException.cs
│ ├── DataTypeNotAvailableException.cs
│ ├── UniqueConstraintException.cs
│ ├── NotSupportedByDatabaseException.cs
│ ├── TableNotFoundException.cs
│ ├── DatabaseException.cs
│ └── NotSupportedByDialect.cs
├── SharpDbConfig.cs
├── Util
│ ├── IntExtensions.cs
│ ├── StringHelper.cs
│ └── ReflectionHelper.cs
├── ISharpFactory.cs
├── Log
│ └── SharpDataLogging.cs
├── TableRow.cs
├── ExceptionHelper.cs
├── In.cs
├── IDataProvider.cs
├── InOut.cs
├── DbFactory.cs
├── Out.cs
├── DataReaderToResultSetMapper.cs
├── IDataClientObjectEx.cs
├── IDatabase.cs
├── ResultSet.cs
├── SharpData.csproj
├── ResultSetExtensions.cs
├── IDataClientEx.cs
├── GenericDbTypeMap.cs
├── IDataClient.cs
├── FakeDataClient.cs
└── SharpFactory.cs
├── SharpData.Sample.NetFull
├── App.config
├── User.cs
├── Program.cs
├── Sample.cs
├── Properties
│ └── AssemblyInfo.cs
└── SharpData.Sample.NetFull.csproj
├── SharpData.Tests
├── Dialects
│ ├── DialectTests.cs
│ ├── Data
│ │ ├── MySqlDialectTests.cs
│ │ ├── SqLiteDialectTests.cs
│ │ ├── PostgreSqlDialectTests.cs
│ │ ├── OracleDialectTests.cs
│ │ └── SqlServerDialectTests.cs
│ └── Schema
│ │ ├── SqLiteDialectSchemaTests.cs
│ │ ├── SqlServerDialectSchemaTests.cs
│ │ ├── MySqlDialectSchemaTests.cs
│ │ ├── PostgreSqlDialectSchemaTests.cs
│ │ └── OracleDialectSchemaTests.cs
├── MultipleTableTests.cs
├── Schema
│ ├── TableTests.cs
│ ├── ColumnTests.cs
│ └── FluentColumnTest.cs
├── CollectionAssert.cs
├── Util
│ └── IntExtensionsTests.cs
├── SharpData.Tests.csproj
├── DataParameterCollectionFake.cs
├── AssertSql.cs
├── Filters
│ ├── CompareOperatorToSymbolTests.cs
│ └── FilterTests.cs
├── DataReaderToResultSetMapperTests.cs
├── FilterTests.cs
└── WhereBuilderTests.cs
├── SharpData.Sample.Core
├── User.cs
├── SharpData.Sample.Core.csproj
├── Program.cs
└── Example.cs
├── SharpData.Tests.Integration
├── Oracle
│ ├── OracleOdpSchemaTests.cs
│ ├── OracleSpecificExceptionsTests.cs
│ ├── OracleOdpDataClientFactoryTests.cs
│ ├── OracleOdpDatabaseTests.cs
│ ├── OracleOdpDataTests.cs
│ └── OracleManagedDataTests.cs
├── SqlServer
│ ├── SqlServerDataTests.cs
│ ├── SqlServerSchemaTests.cs
│ ├── SqlServerSpecifcExceptionsTests.cs
│ └── SqlServerDataClientFactoryTests.cs
├── PostgreSql
│ ├── PostgreSqlDataTests.cs
│ ├── PostgreSqlSchemaTests.cs
│ ├── PostgreSqlSpecificExceptionsTests.cs
│ └── PostgreSqlDataClientFactoryTests.cs
├── ConnectionStrings.cs
├── CollectionAssert.cs
├── AssertSql.cs
├── Mysql
│ ├── MySqlDataClientFactoryTests.cs
│ ├── MySqlDataTests.cs
│ └── MySqlSchemaTests.cs
├── SQLite
│ ├── SqLiteDataClientFactoryTests.cs
│ ├── SqLiteDataTests.cs
│ └── SqLiteSchemaTests.cs
├── Data
│ ├── DataClientFactoryTests.cs
│ └── DataClientTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── DBBuilder.cs
└── App.config
├── LICENSE
├── README.md
├── .gitattributes
└── SharpData.sln
/SharpData/Filters/LogicOperator.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Query {
2 | public enum LogicOperator {
3 | And,
4 | Or
5 | }
6 | }
--------------------------------------------------------------------------------
/SharpData/Schema/OrderByDirection.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Schema {
2 | public enum OrderByDirection {
3 | Ascending,
4 | Descending
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/SharpData/Filters/FilterParameterType.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Query {
2 | public enum FilterParameterType {
3 | Column,
4 | Value
5 | }
6 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/IRemoveFromTable.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Fluent {
2 | public interface IRemoveFromTable {
3 | void FromTable(string tableName);
4 | }
5 | }
--------------------------------------------------------------------------------
/SharpData/Filters/FilterLogic.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Query;
2 |
3 | namespace SharpData.Filters {
4 | public class FilterLogic : Filter {
5 | public LogicOperator LogicOperator { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/SharpData/Filters/FilterCondition.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Query;
2 |
3 | namespace SharpData.Filters {
4 | public class FilterCondition : Filter {
5 | public CompareOperator CompareOperator { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/IFluentRename.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Fluent {
2 | public interface IFluentRename {
3 | IRenameTableTo Table(string tableName);
4 | IRenameColumnOfTable Column(string columnName);
5 | }
6 | }
--------------------------------------------------------------------------------
/SharpData.Sample.NetFull/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SharpData.Sample.NetFull/User.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Sample {
2 | public class User {
3 | public int Id { get; set; }
4 | public string Username { get; set; }
5 | public string Password { get; set; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/SharpData/Databases/DatabaseKind.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Databases {
2 | public enum DatabaseKind {
3 | Oracle,
4 | SqlServer,
5 | MySql,
6 | SqLite,
7 | OleDb,
8 | PostgreSql
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData/Databases/MySql/MySqlDataClient.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Databases.MySql {
2 | public class MySqlDataClient : DataClient {
3 | public MySqlDataClient(IDatabase database, Dialect dialect) : base(database, dialect) {
4 | }
5 | }
6 | }
--------------------------------------------------------------------------------
/SharpData/Databases/IDbTypeMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace SharpData.Databases {
7 | public interface IDbTypeMap {
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/SharpData/Exceptions/ProviderNotFoundException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData.Exceptions {
4 | public class ProviderNotFoundException : Exception {
5 | public ProviderNotFoundException(string message) : base(message) { }
6 | }
7 | }
--------------------------------------------------------------------------------
/SharpData/Databases/Oracle/OracleDataClient.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Databases.Oracle {
2 | public class OracleDataClient : DataClient {
3 | public OracleDataClient(IDatabase database, Dialect dialect) : base(database, dialect) {
4 | }
5 | }
6 | }
--------------------------------------------------------------------------------
/SharpData/Databases/PostgreSql/PostgreSqlDataClient.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Databases.PostgreSql {
2 | public class PostgreSqlDataClient : DataClient {
3 | public PostgreSqlDataClient(IDatabase database, Dialect dialect) : base(database, dialect) { }
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/SharpData/Databases/SqLite/SqLiteDataClient.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Databases.SqLite {
2 | public class SqLiteDataClient : DataClient {
3 | public SqLiteDataClient(IDatabase database, Dialect dialect)
4 | : base(database, dialect) {
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/SharpData/Exceptions/DataTypeNotAvailableException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData.Exceptions {
4 |
5 | public class DataTypeNotAvailableException : Exception {
6 | public DataTypeNotAvailableException(string message) : base(message) { }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/SharpData.Tests/Dialects/DialectTests.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 | using SharpData;
3 |
4 | namespace Sharp.Tests.Data.Databases {
5 | public abstract class DialectTests {
6 | protected string TABLE_NAME = "myTable";
7 | protected Dialect _dialect;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/SharpData/Schema/OnDelete.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpData.Schema {
7 | public enum OnDelete {
8 | NoAction,
9 | Cascade,
10 | SetNull
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SharpData/Databases/PostgreSql/SqlColumnStructure.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Databases.PostgreSql {
2 | internal class SqlColumnStructure {
3 | public string Type { get; set; }
4 | public string Nullable { get; set; }
5 | public string Default { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/SharpData/Filters/CompareOperator.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Query {
2 | public enum CompareOperator {
3 | Equals,
4 | GreaterThan,
5 | LessThan,
6 | GreaterOrEqualThan,
7 | LessOrEqualThan,
8 | NotEquals,
9 | Is
10 | }
11 | }
--------------------------------------------------------------------------------
/SharpData/Filters/LogicOperatorToSymbol.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using SharpData.Query;
3 |
4 | namespace SharpData.Filters {
5 | public static class LogicOperatorToSymbol {
6 |
7 | public static string Get(LogicOperator logicOperator) {
8 | return logicOperator.ToString();
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SharpData/SharpDbConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData {
4 | public class SharpDbConfig {
5 | public string DbProviderName { get; set; }
6 | public IDataProvider DataProvider { get; set; }
7 | public Database Database { get; set; }
8 | public DataClient DataClient { get; set; }
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData/Exceptions/UniqueConstraintException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData.Exceptions {
4 | public class UniqueConstraintException : DatabaseException {
5 | public UniqueConstraintException(string message, Exception innerException, string sql)
6 | : base(message, innerException, sql) {
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/SharpData/Exceptions/NotSupportedByDatabaseException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData.Exceptions {
4 | public class NotSupportedByDatabaseException : DatabaseException {
5 | public NotSupportedByDatabaseException(string message, Exception innerException, string sql) : base(message, innerException, sql) {
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/SharpData/Databases/SqlServer/OleDbDbFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 |
3 | namespace SharpData.Databases.SqlServer {
4 | public class OleDbDbFactory : SqlServerDbFactory {
5 | public OleDbDbFactory(DbProviderFactory dbProviderFactory, string connectionString)
6 | : base(dbProviderFactory, connectionString) {
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/RemoveTable.cs:
--------------------------------------------------------------------------------
1 | using SharpData;
2 |
3 | namespace SharpData.Fluent {
4 | public class RemoveTable : DataClientAction {
5 | public RemoveTable(IDataClient dataClient) : base(dataClient) {}
6 |
7 | protected override void ExecuteInternal() {
8 | DataClient.RemoveTable(TableNames[0]);
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/RemoveColumn.cs:
--------------------------------------------------------------------------------
1 | using SharpData;
2 |
3 | namespace SharpData.Fluent {
4 | public class RemoveColumn : RemoveItemFromTable {
5 |
6 | public RemoveColumn(IDataClient dataClient) : base(dataClient) {}
7 |
8 | protected override void ExecuteInternal() {
9 | DataClient.RemoveColumn(TableNames[0], ItemName);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/SharpData.Sample.Core/User.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Sample {
2 | public class User {
3 | public int Id { get; set; }
4 | public string Username { get; set; }
5 | public string Password { get; set; }
6 | }
7 |
8 | public class UserInsert {
9 | public string Username { get; set; }
10 | public string Password { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SharpData/Util/IntExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpData.Util {
7 | public static class IntExtensions {
8 |
9 | public static bool Between(this Int32 value, int smaller, int bigger) {
10 | return value >= smaller && value <= bigger;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/Oracle/OracleOdpSchemaTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.Oracle {
5 | public class OracleOdpSchemaTests : DataClientSchemaTests {
6 | protected override DbProviderType GetDataProviderName() {
7 | return DbProviderType.OracleOdp;
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/SqlServer/SqlServerDataTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.SqlServer {
5 | public class SqlServerDataTests : DataClientDataTests {
6 | protected override DbProviderType GetDataProviderName() {
7 | return DbProviderType.SqlServer;
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/ReversableFluentActions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData.Fluent {
4 | public class ReversibleFluentActions {
5 | public event Action OnAction;
6 |
7 | public void FireOnAction(DataClientAction action) {
8 | if (OnAction != null) {
9 | OnAction(action);
10 | }
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/PostgreSql/PostgreSqlDataTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.PostgreSql {
5 | public class PostgreSqlDataTests : DataClientDataTests {
6 | protected override DbProviderType GetDataProviderName() {
7 | return DbProviderType.PostgreSql;
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/SqlServer/SqlServerSchemaTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.SqlServer {
5 | public class SqlServerSchemaTests : DataClientSchemaTests {
6 | protected override DbProviderType GetDataProviderName() {
7 | return DbProviderType.SqlServer;
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData/ISharpFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 |
3 | namespace SharpData {
4 | public interface ISharpFactory {
5 | string ConnectionString { get; }
6 | DbProviderFactory DbProviderFactory { get; }
7 | IDataProvider CreateDataProvider();
8 | IDatabase CreateDatabase();
9 | IDataClient CreateDataClient();
10 | Dialect CreateDialect();
11 | }
12 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/PostgreSql/PostgreSqlSchemaTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.PostgreSql {
5 | public class PostgreSqlSchemaTests : DataClientSchemaTests {
6 | protected override DbProviderType GetDataProviderName() {
7 | return DbProviderType.PostgreSql;
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/SharpData/Filters/FilterParameter.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Query;
2 |
3 | namespace SharpData.Filters {
4 | public class FilterParameter {
5 | public object Value { get; set; }
6 | public FilterParameterType FilterParameterType { get; set; }
7 | public bool ValueIsNullOrDBNull {
8 | get {
9 | return Value == null || Value == System.DBNull.Value;
10 | }
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/SharpData/Exceptions/TableNotFoundException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SharpData.Exceptions {
7 | public class TableNotFoundException : DatabaseException {
8 | public TableNotFoundException(string message, Exception innerException, string sql) : base(message, innerException, sql) {
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SharpData/Schema/Table.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SharpData.Schema {
4 |
5 | public class Table {
6 |
7 | public string Name { get; protected set; }
8 | public List Columns { get; protected set; }
9 |
10 | public Table(string name) {
11 | Name = name;
12 | Columns = new List();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/RemoveItem.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Fluent {
2 | public abstract class RemoveItemFromTable : DataClientAction, IRemoveFromTable {
3 | public string ItemName { get; set; }
4 | protected RemoveItemFromTable(IDataClient dataClient) : base(dataClient) {}
5 |
6 | public void FromTable(string tableName) {
7 | SetTableNames(tableName);
8 | Execute();
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/SharpData/Log/SharpDataLogging.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 |
3 | namespace SharpData.Log {
4 | public static class SharpDataLogging {
5 | public static ILoggerFactory LoggerFactory { get; set; } = new LoggerFactory();
6 | public static ILogger CreateLogger() => LoggerFactory.CreateLogger();
7 | public static ILogger CreateLogger(string category) => LoggerFactory.CreateLogger(category);
8 | }
9 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/Count.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Filters;
2 |
3 | namespace SharpData.Fluent {
4 | public class Count : DataClientAction {
5 |
6 | public Filter Filter { get; set; }
7 |
8 | public int CountedRows { get; set; }
9 |
10 | public Count(IDataClient dataClient) : base(dataClient) { }
11 |
12 | protected override void ExecuteInternal() {
13 | CountedRows = DataClient.CountSql(TableNames[0], Filter);
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/SharpData/Databases/SqLite/SQLiteProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 |
3 | namespace SharpData.Databases.SqLite {
4 | public class SqLiteProvider : DataProvider {
5 | public SqLiteProvider(DbProviderFactory dbProviderFactory) : base(dbProviderFactory) {
6 | }
7 |
8 | public override DbProviderType Name => DbProviderType.SqLite;
9 | public override DatabaseKind DatabaseKind => DatabaseKind.Oracle;
10 | }
11 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/RemovePrimaryKey.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Fluent {
2 | public class RemovePrimaryKey : RemoveItemFromTable {
3 | public RemovePrimaryKey(IDataClient dataClient, string primaryKeyName) : base(dataClient) {
4 | ItemName = primaryKeyName;
5 | }
6 |
7 | protected override void ExecuteInternal() {
8 | DataClient.RemovePrimaryKey(FirstTableName, ItemName);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SharpData/Fluent/RemoveForeignKey.cs:
--------------------------------------------------------------------------------
1 | using SharpData;
2 |
3 | namespace SharpData.Fluent {
4 | public class RemoveForeignKey : RemoveItemFromTable {
5 |
6 | public RemoveForeignKey(IDataClient dataClient, string foreignKeyName) : base(dataClient) {
7 | ItemName = foreignKeyName;
8 | }
9 |
10 | protected override void ExecuteInternal() {
11 | DataClient.RemoveForeignKey(ItemName, TableNames[0]);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/RemoveIndexKey.cs:
--------------------------------------------------------------------------------
1 | using SharpData;
2 |
3 | namespace SharpData.Fluent {
4 | public class RemoveIndexKey : RemoveItemFromTable, IRemoveFromTable {
5 | public RemoveIndexKey(IDataClient dataClient, string indexKeyName) : base(dataClient) {
6 | ItemName = indexKeyName;
7 | }
8 |
9 | protected override void ExecuteInternal() {
10 | DataClient.RemoveIndex(ItemName, TableNames[0]);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/Oracle/OracleSpecificExceptionsTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.Oracle {
5 | public class OracleSpecificExceptionsTests : SpecificExceptionsTests {
6 | public OracleSpecificExceptionsTests() {
7 | _dataClient = DBBuilder.GetDataClient(DbProviderType.OracleOdp);
8 | _database = _dataClient.Database;
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/SharpData.Tests/MultipleTableTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Moq;
6 | using Xunit;
7 | using SharpData;
8 | using SharpData.Databases;
9 | using SharpData.Filters;
10 |
11 | namespace Sharp.Tests.Data {
12 |
13 | public class MultipleTableTests {
14 |
15 | private Mock _dialect;
16 |
17 | [Fact]
18 | public void Test() {
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/SharpData/Fluent/Delete.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Filters;
2 |
3 | namespace SharpData.Fluent {
4 | public class Delete : DataClientAction {
5 |
6 | public int AfectedRows { get; set; }
7 |
8 | public Filter Filter { get; set; }
9 |
10 | public Delete(IDataClient dataClient) : base(dataClient) { }
11 |
12 | protected override void ExecuteInternal() {
13 | AfectedRows = DataClient.DeleteSql(TableNames[0], Filter);
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/SqlServer/SqlServerSpecifcExceptionsTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.SqlServer {
5 | public class SqlServerSpecifcExceptionsTests : SpecificExceptionsTests {
6 | public SqlServerSpecifcExceptionsTests() {
7 | _dataClient = DBBuilder.GetDataClient(DbProviderType.SqlServer);
8 | _database = _dataClient.Database;
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/SharpData.Tests.Integration/PostgreSql/PostgreSqlSpecificExceptionsTests.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Databases;
2 | using SharpData.Tests.Integration.Data;
3 |
4 | namespace SharpData.Tests.Integration.PostgreSql {
5 | public class PostgreSqlSpecificExceptionsTests : SpecificExceptionsTests {
6 | public PostgreSqlSpecificExceptionsTests() {
7 | _dataClient = DBBuilder.GetDataClient(DbProviderType.PostgreSql);
8 | _database = _dataClient.Database;
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SharpData/Databases/Oracle/OracleOdpDbFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Common;
2 |
3 | namespace SharpData.Databases.Oracle {
4 | public class OracleOdpDbFactory : OracleManagedDbFactory {
5 | public OracleOdpDbFactory(DbProviderFactory dbProviderFactory, string connectionString)
6 | : base(dbProviderFactory, connectionString) {
7 | }
8 |
9 | public override IDataProvider CreateDataProvider() {
10 | return new OracleOdpProvider(DbProviderFactory);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/SharpData/Exceptions/DatabaseException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharpData {
4 | public class DatabaseException : Exception {
5 |
6 | public string SQL { get; set; }
7 |
8 | public DatabaseException(string message, Exception innerException, string sql)
9 | : base(message, innerException) {
10 | SQL = sql;
11 | }
12 |
13 | public override string ToString() {
14 | return $"Error running SQL: {SQL}\r\n{base.ToString()}";
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/SharpData/Schema/OrderBy.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Schema {
2 | public class OrderBy {
3 | public string ColumnName { get; set; }
4 | public OrderByDirection Direction { get; set; }
5 |
6 | public static OrderBy Ascending(string columnName) {
7 | return new OrderBy {ColumnName = columnName, Direction = OrderByDirection.Ascending };
8 | }
9 |
10 | public static OrderBy Descending(string columnName) {
11 | return new OrderBy { ColumnName = columnName, Direction = OrderByDirection.Descending };
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/IFluentModify.cs:
--------------------------------------------------------------------------------
1 | namespace SharpData.Fluent {
2 | public interface IFluentModify {
3 | ModifyColumn Column(string columnName);
4 | }
5 |
6 | public class FluentModify : IFluentModify {
7 | private IDataClient _dataClient;
8 |
9 | public FluentModify(IDataClient dataClient) {
10 | _dataClient = dataClient;
11 | }
12 |
13 | public ModifyColumn Column(string columnName) {
14 | return new ModifyColumn(_dataClient, columnName);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/SharpData.Tests/Schema/TableTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Xunit;
5 | using SharpData.Schema;
6 |
7 | namespace Sharp.Tests.Data.Schema {
8 |
9 | public class TableTests {
10 |
11 | [Fact]
12 | public void ConstructorTest() {
13 | var table = new Table("name");
14 | Assert.Equal("name", table.Name);
15 | Assert.NotNull(table.Columns);
16 | Assert.Equal(0, table.Columns.Count);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/SharpData.Sample.Core/SharpData.Sample.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/SharpData/Databases/Oracle/OracleReflectionCache.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | namespace SharpData.Databases.Oracle {
4 | public class OracleReflectionCache {
5 | public bool IsCached { get; set; }
6 | public PropertyInfo PropParameterDbType { get; set; }
7 | public PropertyInfo PropBindByName { get; set; }
8 | public PropertyInfo PropArrayBindCount { get; set; }
9 | public object DbTypeRefCursor { get; set; }
10 | public object DbTypeBlob { get; set; }
11 | public object DbTypeDate { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/IFluentAdd.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Schema;
2 |
3 | namespace SharpData.Fluent {
4 | public interface IFluentAdd {
5 | IAddColumnToTable Column(FluentColumn column);
6 | IAddPrimaryKeyOnColumns PrimaryKey(string primaryKeyName);
7 | IAddForeignKeyOnColumn ForeignKey(string foreignKeyName);
8 | IAddUniqueKeyOnColumns UniqueKey(string uniqueKeyName);
9 | DataClientAddIndexKey IndexKey(string indexKeyName);
10 | IAddTableWithColumns Table(string tableName);
11 | IAddCommentColumnOrTable Comment(string comment);
12 | }
13 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/Update.cs:
--------------------------------------------------------------------------------
1 | using SharpData.Filters;
2 |
3 | namespace SharpData.Fluent {
4 | public class Update : DataClientAction {
5 |
6 | public Filter Filter { get; set; }
7 | public string[] Columns { get; set; }
8 | public object[] Values { get; set; }
9 | public int AfectedRows { get; set; }
10 |
11 | public Update(IDataClient dataClient) : base(dataClient) { }
12 |
13 | protected override void ExecuteInternal() {
14 | AfectedRows = DataClient.UpdateSql(TableNames[0], Columns, Values, Filter);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/SharpData/Fluent/RemoveUniqueKey.cs:
--------------------------------------------------------------------------------
1 | using SharpData;
2 |
3 | namespace SharpData.Fluent {
4 | public class RemoveUniqueKey : RemoveItemFromTable {
5 | public RemoveUniqueKey(IDataClient dataClient, string uniqueKeyName) : base(dataClient) {
6 | ItemName = uniqueKeyName;
7 | }
8 |
9 | public void FromTable(string tableName) {
10 | SetTableNames(tableName);
11 | Execute();
12 | }
13 |
14 | protected override void ExecuteInternal() {
15 | DataClient.RemoveUniqueKey(ItemName, TableNames[0]);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/SharpData/TableRow.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SharpData {
4 | public class TableRow : List