Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Commit

Permalink
implemented Postulate.Sql
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfoneil committed Jun 5, 2017
1 parent 65efdea commit 1f42413
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
1 change: 0 additions & 1 deletion Postulate.Mvc/SqlServerDbController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Postulate.Orm;
using System.Web.Mvc;
using System.Web;
using System.Web.Routing;
using Postulate.Orm.Abstract;
using System;
Expand Down
9 changes: 3 additions & 6 deletions SampleWebApp/Controllers/CustomerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
using System.Web;
using System.Web.Mvc;
using Dapper;
using SampleWebApp.Queries;

namespace SampleWebApp.Controllers
{
public class CustomerController : SqlServerDbController<DemoDb2, int>
{
public ActionResult Index()
{
using (var cn = _db.GetConnection())
{
cn.Open();
var list = cn.Query<Customer>("SELECT * FROM [Customer] ORDER BY [LastName]");
return View(list);
}
var list = new AllCustomers().Execute();
return View(list);
}

public ActionResult Create(Customer record)
Expand Down
16 changes: 16 additions & 0 deletions SampleWebApp/Queries/AllCustomers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Postulate.Sql.Abstract;
using Sample.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SampleWebApp.Queries
{
public class AllCustomers : DemoDbQuery<Customer>
{
public AllCustomers() : base("SELECT * FROM [Customer] ORDER BY [LastName], [FirstName]")
{
}
}
}
16 changes: 16 additions & 0 deletions SampleWebApp/Queries/DemoDbQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Postulate.Sql.Abstract;
using Sample.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SampleWebApp.Queries
{
public class DemoDbQuery<TResult> : Query<TResult>
{
public DemoDbQuery(string sql) : base(sql, () => new DemoDb2().GetConnection())
{
}
}
}
5 changes: 5 additions & 0 deletions SampleWebApp/SampleWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Postulate.Sql, Version=1.0.9.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Postulate.Sql.1.0.9\lib\net461\Postulate.Sql.dll</HintPath>
</Reference>
<Reference Include="PostulateOrm, Version=0.9.137.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Postulate.Orm.0.9.137\lib\net461\PostulateOrm.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -208,6 +211,8 @@
<Compile Include="Models\IdentityModels.cs" />
<Compile Include="Models\ManageViewModels.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Queries\AllCustomers.cs" />
<Compile Include="Queries\DemoDbQuery.cs" />
<Compile Include="Startup.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions SampleWebApp/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="Postulate.Orm" version="0.9.137" targetFramework="net461" />
<package id="Postulate.Sql" version="1.0.9" targetFramework="net461" />
<package id="Respond" version="1.2.0" targetFramework="net452" />
<package id="WebGrease" version="1.5.2" targetFramework="net452" />
</packages>

0 comments on commit 1f42413

Please sign in to comment.