Skip to content

Commit dfac6ae

Browse files
committed
init
1 parent d2bc73f commit dfac6ae

File tree

49 files changed

+10315
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10315
-0
lines changed

.vs/RevStack.SQL/v14/.suo

20 KB
Binary file not shown.

Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("RevStack.SQL")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("RevStack.SQL")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("b82ecb41-49a8-4498-9126-e368df3cd0f6")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

RevStack.SQL.csproj

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{B82ECB41-49A8-4498-9126-E368DF3CD0F6}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>RevStack.SQL</RootNamespace>
11+
<AssemblyName>RevStack.SQL</AssemblyName>
12+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, processorArchitecture=MSIL">
35+
<HintPath>packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
36+
<Private>True</Private>
37+
</Reference>
38+
<Reference Include="RevStack.Pattern, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
39+
<SpecificVersion>False</SpecificVersion>
40+
<HintPath>bin\RevStack.Pattern.dll</HintPath>
41+
</Reference>
42+
<Reference Include="ServiceStack.Common, Version=4.0.50.0, Culture=neutral, processorArchitecture=MSIL">
43+
<HintPath>packages\ServiceStack.Common.4.0.50\lib\net40\ServiceStack.Common.dll</HintPath>
44+
<Private>True</Private>
45+
</Reference>
46+
<Reference Include="ServiceStack.Interfaces, Version=4.0.0.0, Culture=neutral, PublicKeyToken=e06fbc6124f57c43, processorArchitecture=MSIL">
47+
<HintPath>packages\ServiceStack.Interfaces.4.0.50\lib\portable-wp80+sl5+net40+win8+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll</HintPath>
48+
<Private>True</Private>
49+
</Reference>
50+
<Reference Include="ServiceStack.OrmLite, Version=4.0.50.0, Culture=neutral, processorArchitecture=MSIL">
51+
<HintPath>packages\ServiceStack.OrmLite.4.0.50\lib\net45\ServiceStack.OrmLite.dll</HintPath>
52+
<Private>True</Private>
53+
</Reference>
54+
<Reference Include="ServiceStack.OrmLite.SqlServer, Version=4.0.50.0, Culture=neutral, processorArchitecture=MSIL">
55+
<HintPath>packages\ServiceStack.OrmLite.SqlServer.4.0.50\lib\net45\ServiceStack.OrmLite.SqlServer.dll</HintPath>
56+
<Private>True</Private>
57+
</Reference>
58+
<Reference Include="ServiceStack.Text, Version=4.0.50.0, Culture=neutral, processorArchitecture=MSIL">
59+
<HintPath>packages\ServiceStack.Text.4.0.50\lib\net40\ServiceStack.Text.dll</HintPath>
60+
<Private>True</Private>
61+
</Reference>
62+
<Reference Include="System" />
63+
<Reference Include="System.ComponentModel.DataAnnotations" />
64+
<Reference Include="System.Configuration" />
65+
<Reference Include="System.Core" />
66+
<Reference Include="System.Xml.Linq" />
67+
<Reference Include="System.Data.DataSetExtensions" />
68+
<Reference Include="Microsoft.CSharp" />
69+
<Reference Include="System.Data" />
70+
<Reference Include="System.Net.Http" />
71+
<Reference Include="System.Xml" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<Compile Include="Properties\AssemblyInfo.cs" />
75+
<Compile Include="SQLDataContext.cs" />
76+
<Compile Include="SQLRepository.cs" />
77+
<Compile Include="SQLServerDataProvider.cs" />
78+
</ItemGroup>
79+
<ItemGroup>
80+
<None Include="packages.config" />
81+
</ItemGroup>
82+
<ItemGroup />
83+
<ItemGroup>
84+
<Content Include="bin\RevStack.Pattern.dll" />
85+
</ItemGroup>
86+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
87+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
88+
Other similar extension points exist, see Microsoft.Common.targets.
89+
<Target Name="BeforeBuild">
90+
</Target>
91+
<Target Name="AfterBuild">
92+
</Target>
93+
-->
94+
</Project>

RevStack.SQL.csproj.user

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ProjectView>ShowAllFiles</ProjectView>
5+
</PropertyGroup>
6+
</Project>

RevStack.SQL.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.23107.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevStack.SQL", "RevStack.SQL.csproj", "{B82ECB41-49A8-4498-9126-E368DF3CD0F6}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B82ECB41-49A8-4498-9126-E368DF3CD0F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B82ECB41-49A8-4498-9126-E368DF3CD0F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B82ECB41-49A8-4498-9126-E368DF3CD0F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B82ECB41-49A8-4498-9126-E368DF3CD0F6}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

SQLDataContext.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Data.SqlClient;
5+
using System.Configuration;
6+
using System.Data;
7+
using System.Data.Common;
8+
using System.Reflection;
9+
using System.Linq.Expressions;
10+
11+
namespace RevStack.SQL
12+
{
13+
public class SQLDataContext
14+
{
15+
private readonly SQLServerDataProvider _database;
16+
17+
public string ConnectionString { get; set; }
18+
19+
public SQLDataContext()
20+
{
21+
string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
22+
_database = new SQLServerDataProvider(connectionString);
23+
ConnectionString = connectionString;
24+
}
25+
26+
public SQLDataContext(string connectionString)
27+
{
28+
_database = new SQLServerDataProvider(connectionString);
29+
ConnectionString = connectionString;
30+
}
31+
32+
internal SQLServerDataProvider DataProvider
33+
{
34+
get
35+
{
36+
return _database;
37+
}
38+
}
39+
}
40+
}

SQLRepository.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using RevStack.Pattern;
7+
using System.Linq.Expressions;
8+
using System.Collections.ObjectModel;
9+
10+
namespace RevStack.SQL
11+
{
12+
public class SQLRepository<TEntity, TKey> : IRepository<TEntity, TKey> where TEntity : class, IEntity<TKey>
13+
{
14+
private readonly SQLServerDataProvider _database;
15+
16+
public SQLRepository(SQLDataContext context)
17+
{
18+
_database = context.DataProvider;
19+
}
20+
21+
public IEnumerable<TEntity> Get()
22+
{
23+
return _database.Find<TEntity>().AsEnumerable<TEntity>();
24+
}
25+
26+
public IQueryable<TEntity> Find(Expression<Func<TEntity, bool>> predicate)
27+
{
28+
return _database.Find<TEntity>(predicate);
29+
}
30+
31+
public TEntity Add(TEntity entity)
32+
{
33+
_database.Insert<TEntity>(entity);
34+
return entity;
35+
}
36+
37+
public TEntity Update(TEntity entity)
38+
{
39+
_database.Update<TEntity>(entity);
40+
return entity;
41+
}
42+
43+
public void Delete(TEntity entity)
44+
{
45+
_database.Delete<TEntity>(entity);
46+
}
47+
48+
public void Execute(string command)
49+
{
50+
_database.Execute(command);
51+
}
52+
}
53+
}

SQLServerDataProvider.cs

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Data.SqlClient;
5+
using System.Configuration;
6+
using System.Data;
7+
using System.Data.Common;
8+
using System.Reflection;
9+
using System.Linq.Expressions;
10+
using ServiceStack.OrmLite;
11+
12+
namespace RevStack.SQL
13+
{
14+
public class SQLServerDataProvider
15+
{
16+
protected OrmLiteConnectionFactory DbFactory;
17+
18+
private SQLServerDataProvider() { }
19+
20+
public SQLServerDataProvider(string connectionString)
21+
{
22+
Init(connectionString);
23+
}
24+
25+
OrmLiteConnectionFactory Init(string connStr)
26+
{
27+
ConnectionString = connStr;
28+
IOrmLiteDialectProvider dialectProvider = new ServiceStack.OrmLite.SqlServer.SqlServerOrmLiteDialectProvider();
29+
DbFactory = new OrmLiteConnectionFactory(ConnectionString, dialectProvider);
30+
return DbFactory;
31+
}
32+
33+
public string ConnectionString { get; set; }
34+
35+
public void Insert<TEntity>(TEntity entity)
36+
{
37+
using (var db = DbFactory.OpenDbConnection())
38+
{
39+
//db.CreateTableIfNotExists<TEntity>();
40+
db.Save<TEntity>(entity, references: true);
41+
}
42+
}
43+
44+
public void Update<TEntity>(TEntity entity)
45+
{
46+
using (var db = DbFactory.OpenDbConnection())
47+
{
48+
//db.CreateTableIfNotExists<TEntity>();
49+
db.Save<TEntity>(entity, references: true);
50+
}
51+
}
52+
53+
public void Delete<TEntity>(TEntity entity)
54+
{
55+
Type type = typeof(TEntity);
56+
PropertyInfo property = type.GetProperty("Id");
57+
object id = property.GetValue(entity);
58+
using (var db = DbFactory.OpenDbConnection())
59+
{
60+
db.DeleteById<TEntity>(id);
61+
}
62+
}
63+
64+
public TEntity Get<TEntity>(object id)
65+
{
66+
TEntity entity;
67+
68+
using (var db = DbFactory.OpenDbConnection())
69+
{
70+
entity = db.LoadSingleById<TEntity>(id);
71+
}
72+
73+
return entity;
74+
}
75+
76+
public void Execute(string command)
77+
{
78+
using (var db = DbFactory.OpenDbConnection())
79+
{
80+
db.ExecuteNonQuery(command);
81+
}
82+
}
83+
84+
public IQueryable<TEntity> Find<TEntity>(Expression<Func<TEntity, bool>> expression)
85+
{
86+
IQueryable<TEntity> query;
87+
88+
using (var db = DbFactory.OpenDbConnection())
89+
{
90+
var q = db.LoadSelect<TEntity>(expression);
91+
query = q.AsQueryable();
92+
}
93+
94+
return query;
95+
}
96+
97+
public IQueryable<TEntity> Find<TEntity>()
98+
{
99+
IQueryable<TEntity> query;
100+
101+
using (var db = DbFactory.OpenDbConnection())
102+
{
103+
var q = db.LoadSelect<TEntity>();
104+
query = q.AsQueryable();
105+
}
106+
107+
return query;
108+
}
109+
}
110+
}

bin/RevStack.Pattern.dll

6 KB
Binary file not shown.
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\obj\Debug\RevStack.SQL.csprojResolveAssemblyReference.cache
2+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\bin\Debug\RevStack.SQL.dll
3+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\bin\Debug\RevStack.SQL.pdb
4+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\bin\Debug\Dapper.dll
5+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\bin\Debug\RevStack.Pattern.dll
6+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\bin\Debug\Dapper.pdb
7+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\bin\Debug\Dapper.xml
8+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\obj\Debug\RevStack.SQL.dll
9+
C:\Users\David\Repositories\RevStack.SQL\RevStack.SQL\obj\Debug\RevStack.SQL.pdb

obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

Whitespace-only changes.

obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

Whitespace-only changes.

obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

Whitespace-only changes.

packages.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Dapper" version="1.42" targetFramework="net45" />
4+
<package id="ServiceStack.Common" version="4.0.50" targetFramework="net46" />
5+
<package id="ServiceStack.Interfaces" version="4.0.50" targetFramework="net46" />
6+
<package id="ServiceStack.OrmLite" version="4.0.50" targetFramework="net46" />
7+
<package id="ServiceStack.OrmLite.SqlServer" version="4.0.50" targetFramework="net46" />
8+
<package id="ServiceStack.Text" version="4.0.50" targetFramework="net46" />
9+
</packages>
303 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Default Extension="nuspec" ContentType="application/octet" /><Default Extension="dll" ContentType="application/octet" /><Default Extension="pdb" ContentType="application/octet" /><Default Extension="xml" ContentType="application/octet" /><Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /></Types>
83 KB
Binary file not shown.
160 KB
Binary file not shown.

0 commit comments

Comments
 (0)