Skip to content

Commit 516d095

Browse files
committed
Adding SQLite provider
1 parent 33e9cab commit 516d095

39 files changed

+2013
-382
lines changed

DataCommander.Foundation/DataCommander.Foundation-4.0.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@
390390
<Compile Include="Linq\EnumExtensions.cs" />
391391
<Compile Include="Linq\Extensions.cs" />
392392
<Compile Include="Linq\FuncExtensions.cs" />
393+
<Compile Include="Linq\IdentityFunction.cs" />
393394
<Compile Include="Linq\IDictionaryExtensions.cs" />
394395
<Compile Include="Collections\IndexableCollection\SequenceIndex.cs" />
395396
<Compile Include="Collections\IndexableCollection\UniqueListIndex.cs" />

DataCommander.Foundation/Linq/IEnumerableExtensions.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ public static MinMaxResult<TSource> MinMax<TSource, TResult>(
312312
return source.MinMax(where, select, Comparer<TResult>.Default);
313313
}
314314

315+
/// <summary>
316+
///
317+
/// </summary>
318+
/// <typeparam name="TSource"></typeparam>
319+
/// <param name="source"></param>
320+
/// <returns></returns>
321+
public static IOrderedEnumerable<TSource> OrderBy<TSource>(this IEnumerable<TSource> source)
322+
{
323+
return source.OrderBy(IdentityFunction<TSource>.Instance);
324+
}
325+
315326
/// <summary>
316327
///
317328
/// </summary>
@@ -618,9 +629,9 @@ public static IEnumerable<TResult> Where<TSource, TResult>(
618629

619630
private static T Clone<T>(T source)
620631
{
621-
var cloneable = (ICloneable) source;
632+
var cloneable = (ICloneable)source;
622633
Object cloneObject = cloneable.Clone();
623-
T clone = (T) cloneObject;
634+
T clone = (T)cloneObject;
624635
return clone;
625636
}
626637

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace DataCommander.Foundation.Linq
2+
{
3+
using System;
4+
5+
/// <summary>
6+
///
7+
/// </summary>
8+
/// <typeparam name="TElement"></typeparam>
9+
public static class IdentityFunction<TElement>
10+
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
public static Func<TElement, TElement> Instance
15+
{
16+
get
17+
{
18+
return x => x;
19+
}
20+
}
21+
}
22+
}

DataCommander.Foundation/Selection.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
/// </summary>
99
public static class Selection
1010
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
/// <typeparam name="TArgument"></typeparam>
15+
/// <param name="argument"></param>
16+
/// <returns></returns>
17+
public static ArgumentEqualsSelection<TArgument> CreateArgumentEqualsSelection<TArgument>(TArgument argument) where TArgument : IEquatable<TArgument>
18+
{
19+
return new ArgumentEqualsSelection<TArgument>(argument);
20+
}
21+
1122
/// <summary>
1223
///
1324
/// </summary>
@@ -30,6 +41,57 @@ public static TypeIsSelection CreateTypeIsSelection(Type type)
3041
}
3142
}
3243

44+
/// <summary>
45+
///
46+
/// </summary>
47+
/// <typeparam name="TArgument"></typeparam>
48+
public sealed class ArgumentEqualsSelection<TArgument> where TArgument : IEquatable<TArgument>
49+
{
50+
private readonly TArgument argument;
51+
private bool selected;
52+
53+
/// <summary>
54+
///
55+
/// </summary>
56+
/// <param name="argument"></param>
57+
public ArgumentEqualsSelection(TArgument argument)
58+
{
59+
this.argument = argument;
60+
}
61+
62+
/// <summary>
63+
///
64+
/// </summary>
65+
/// <param name="other"></param>
66+
/// <param name="action"></param>
67+
/// <returns></returns>
68+
public ArgumentEqualsSelection<TArgument> IfArgumentEquals(TArgument other, Action action)
69+
{
70+
Contract.Requires(action != null);
71+
72+
if (!this.selected)
73+
{
74+
this.selected = this.argument.Equals(other);
75+
if (this.selected)
76+
{
77+
action();
78+
}
79+
}
80+
81+
return this;
82+
}
83+
84+
public void Else(Action action)
85+
{
86+
Contract.Requires(action != null);
87+
88+
if (!this.selected)
89+
{
90+
action();
91+
}
92+
}
93+
}
94+
3395
/// <summary>
3496
///
3597
/// </summary>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
namespace DataCommander.Providers.SQLite
2+
{
3+
using System;
4+
using System.Data.SQLite;
5+
using DataCommander.Foundation.Diagnostics;
6+
using DataCommander.Providers;
7+
8+
internal sealed class Connection : ConnectionBase
9+
{
10+
private static ILog log = LogFactory.Instance.GetCurrentTypeLog();
11+
private SQLiteConnection sqliteConnection;
12+
private string connectionName;
13+
14+
public Connection( string connectionString )
15+
{
16+
this.sqliteConnection = new SQLiteConnection( connectionString );
17+
// this.sqliteConnection.Flags = SQLiteConnectionFlags.LogAll;
18+
// this.sqliteConnection.Trace += this.sqliteConnection_Trace;
19+
this.Connection = this.sqliteConnection;
20+
}
21+
22+
void SQLiteLog_Log( object sender, LogEventArgs e )
23+
{
24+
}
25+
26+
private void sqliteConnection_Trace( object sender, TraceEventArgs e )
27+
{
28+
log.Write( LogLevel.Trace, e.Statement );
29+
}
30+
31+
public override string ConnectionName
32+
{
33+
get
34+
{
35+
return this.connectionName;
36+
}
37+
38+
set
39+
{
40+
this.connectionName = value;
41+
}
42+
}
43+
44+
public override void Open()
45+
{
46+
sqliteConnection.Open();
47+
}
48+
49+
public override System.Data.IDbCommand CreateCommand()
50+
{
51+
return sqliteConnection.CreateCommand();
52+
}
53+
54+
public override string Caption
55+
{
56+
get
57+
{
58+
return sqliteConnection.DataSource;
59+
}
60+
}
61+
62+
public override string DataSource
63+
{
64+
get
65+
{
66+
return sqliteConnection.DataSource;
67+
}
68+
}
69+
70+
protected override void SetDatabase(string database)
71+
{
72+
throw new Exception("The method or operation is not implemented.");
73+
}
74+
75+
public override string ServerVersion
76+
{
77+
get
78+
{
79+
return sqliteConnection.ServerVersion;
80+
}
81+
}
82+
83+
public override int TransactionCount
84+
{
85+
get
86+
{
87+
// TODO
88+
return 0;
89+
}
90+
}
91+
}
92+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>9.0.30729</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{C7B6913B-9B3E-4A09-A053-5B18D8BDAD4D}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>DataCommander.Providers.SQLite</RootNamespace>
12+
<AssemblyName>DataCommander.Providers.SQLite</AssemblyName>
13+
<FileUpgradeFlags>
14+
</FileUpgradeFlags>
15+
<OldToolsVersion>3.5</OldToolsVersion>
16+
<UpgradeBackupLocation>
17+
</UpgradeBackupLocation>
18+
<IsWebBootstrapper>true</IsWebBootstrapper>
19+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
20+
<PublishUrl>http://localhost/DataCommander.Providers.SQLite/</PublishUrl>
21+
<Install>true</Install>
22+
<InstallFrom>Web</InstallFrom>
23+
<UpdateEnabled>true</UpdateEnabled>
24+
<UpdateMode>Foreground</UpdateMode>
25+
<UpdateInterval>7</UpdateInterval>
26+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
27+
<UpdatePeriodically>false</UpdatePeriodically>
28+
<UpdateRequired>false</UpdateRequired>
29+
<MapFileExtensions>true</MapFileExtensions>
30+
<ApplicationRevision>0</ApplicationRevision>
31+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
32+
<UseApplicationTrust>false</UseApplicationTrust>
33+
<BootstrapperEnabled>true</BootstrapperEnabled>
34+
<TargetFrameworkProfile />
35+
</PropertyGroup>
36+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
37+
<DebugSymbols>true</DebugSymbols>
38+
<DebugType>full</DebugType>
39+
<Optimize>false</Optimize>
40+
<OutputPath>..\DataCommander\bin\Debug\</OutputPath>
41+
<DefineConstants>DEBUG;TRACE</DefineConstants>
42+
<ErrorReport>prompt</ErrorReport>
43+
<WarningLevel>4</WarningLevel>
44+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
45+
</PropertyGroup>
46+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
47+
<DebugType>pdbonly</DebugType>
48+
<Optimize>true</Optimize>
49+
<OutputPath>..\DataCommander\bin\Release\</OutputPath>
50+
<DefineConstants>TRACE</DefineConstants>
51+
<ErrorReport>prompt</ErrorReport>
52+
<WarningLevel>4</WarningLevel>
53+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
54+
</PropertyGroup>
55+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
56+
<PlatformTarget>x86</PlatformTarget>
57+
<OutputPath>..\DataCommander\bin\Debug\</OutputPath>
58+
<DefineConstants>TRACE;DEBUG</DefineConstants>
59+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
60+
</PropertyGroup>
61+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
62+
<PlatformTarget>x86</PlatformTarget>
63+
<OutputPath>bin\x86\Release\</OutputPath>
64+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
65+
</PropertyGroup>
66+
<ItemGroup>
67+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
68+
<SpecificVersion>False</SpecificVersion>
69+
<HintPath>..\packages\EntityFramework.6.1.2\lib\net40\EntityFramework.dll</HintPath>
70+
</Reference>
71+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
72+
<SpecificVersion>False</SpecificVersion>
73+
<HintPath>..\packages\EntityFramework.6.1.2\lib\net40\EntityFramework.SqlServer.dll</HintPath>
74+
</Reference>
75+
<Reference Include="System" />
76+
<Reference Include="System.ComponentModel.DataAnnotations" />
77+
<Reference Include="System.Core">
78+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
79+
</Reference>
80+
<Reference Include="System.Data" />
81+
<Reference Include="System.Data.DataSetExtensions" />
82+
<Reference Include="System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
83+
<SpecificVersion>False</SpecificVersion>
84+
<HintPath>..\packages\System.Data.SQLite.Core.1.0.94.0\lib\net40\System.Data.SQLite.dll</HintPath>
85+
</Reference>
86+
<Reference Include="System.Data.SQLite.EF6">
87+
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.94.0\lib\net40\System.Data.SQLite.EF6.dll</HintPath>
88+
</Reference>
89+
<Reference Include="System.Data.SQLite.Linq, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
90+
<SpecificVersion>False</SpecificVersion>
91+
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.94.1\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
92+
</Reference>
93+
<Reference Include="System.Drawing" />
94+
<Reference Include="System.Windows.Forms" />
95+
<Reference Include="System.Xml" />
96+
</ItemGroup>
97+
<ItemGroup>
98+
<Compile Include="Connection.cs" />
99+
<Compile Include="ObjectExplorer\DatabaseNode.cs" />
100+
<Compile Include="ObjectExplorer\DatabaseCollectionNode.cs" />
101+
<Compile Include="ObjectExplorer\IndexCollectionNode.cs" />
102+
<Compile Include="IndexNode.cs" />
103+
<Compile Include="ObjectExplorer\TableNode.cs" />
104+
<Compile Include="ObjectExplorer\ObjectExplorer.cs" />
105+
<Compile Include="Properties\AssemblyInfo.cs" />
106+
<Compile Include="SQLiteDataReaderHelper.cs" />
107+
<Compile Include="SQLiteProvider.cs" />
108+
<Compile Include="ObjectExplorer\TableCollectionNode.cs" />
109+
</ItemGroup>
110+
<ItemGroup>
111+
<ProjectReference Include="..\DataCommander.Foundation\DataCommander.Foundation-4.0.csproj">
112+
<Project>{1bacf0aa-4122-4c10-a8d2-248542af054c}</Project>
113+
<Name>DataCommander.Foundation-4.0</Name>
114+
</ProjectReference>
115+
<ProjectReference Include="..\DataCommander.Providers\DataCommander.Providers.csproj">
116+
<Project>{31A30A80-D1B6-4867-A65E-188DE9E912C8}</Project>
117+
<Name>DataCommander.Providers</Name>
118+
</ProjectReference>
119+
</ItemGroup>
120+
<ItemGroup>
121+
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
122+
<Visible>False</Visible>
123+
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
124+
<Install>false</Install>
125+
</BootstrapperPackage>
126+
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
127+
<Visible>False</Visible>
128+
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
129+
<Install>true</Install>
130+
</BootstrapperPackage>
131+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
132+
<Visible>False</Visible>
133+
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
134+
<Install>false</Install>
135+
</BootstrapperPackage>
136+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
137+
<Visible>False</Visible>
138+
<ProductName>.NET Framework 3.5</ProductName>
139+
<Install>false</Install>
140+
</BootstrapperPackage>
141+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
142+
<Visible>False</Visible>
143+
<ProductName>.NET Framework 3.5 SP1</ProductName>
144+
<Install>false</Install>
145+
</BootstrapperPackage>
146+
</ItemGroup>
147+
<ItemGroup>
148+
<None Include="app.config" />
149+
<None Include="packages.config" />
150+
</ItemGroup>
151+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
152+
<Import Project="..\packages\System.Data.SQLite.Core.1.0.94.0\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.94.0\build\net40\System.Data.SQLite.Core.targets')" />
153+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
154+
<PropertyGroup>
155+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
156+
</PropertyGroup>
157+
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.94.0\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.94.0\build\net40\System.Data.SQLite.Core.targets'))" />
158+
</Target>
159+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
160+
Other similar extension points exist, see Microsoft.Common.targets.
161+
<Target Name="BeforeBuild">
162+
</Target>
163+
<Target Name="AfterBuild">
164+
</Target>
165+
-->
166+
</Project>

0 commit comments

Comments
 (0)