Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using ProductCatalog.Models;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProductCatalog.Controllers
Expand Down Expand Up @@ -46,5 +47,22 @@ public IActionResult Report2()
ViewData["page"] = "report2";
return View();
}

[HttpGet(Name = "GetAll")]
public IEnumerable<Product> GetAll()
{
return _context.Products.AsEnumerable<Product>();
}

[HttpGet("GetById")]
public IActionResult GetById(int id)
{
var product = _context.Products.FirstOrDefault(p=>p.ProductId == id);
if (product == null)
{
return NotFound();
}
return new ObjectResult(product);
}
}
}
11 changes: 6 additions & 5 deletions samples/demos/belgrade-product-catalog-demo/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Belgrade.SqlClient.SqlDb;
using Belgrade.SqlClient;
using Belgrade.SqlClient.SqlDb;
using Belgrade.SqlClient.SqlDb.Rls;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand Down Expand Up @@ -58,14 +59,14 @@ public void ConfigureServices(IServiceCollection services)
services.AddDbContext<ProductCatalogContext>(options => options.UseSqlServer(new SqlConnection(ConnString)));

// Adding data access services/components.
services.AddTransient(
services.AddTransient<IQueryPipe>(
sp => new QueryPipe(new SqlConnection(ConnString))
.AddRls("CompanyID",() => GetCompanyIdFromSession(sp))
//.AddRls("CompanyID",() => GetCompanyIdFromSession(sp))
);

services.AddTransient(
services.AddTransient<ICommand>(
sp => new Command(new SqlConnection(ConnString))
.AddRls("CompanyID", () => GetCompanyIdFromSession(sp))
//.AddRls("CompanyID", () => GetCompanyIdFromSession(sp))
);

//// Add framework services.
Expand Down
2 changes: 1 addition & 1 deletion samples/demos/belgrade-product-catalog-demo/project.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"Belgrade.Sql.Client": "0.6.2",
"Belgrade.Sql.Client": "0.6.5",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
Expand Down
36 changes: 36 additions & 0 deletions samples/demos/belgrade-product-catalog-demo/sql-scripts/8. bcp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CREATE TABLE Orders (
OrderID int,
OrderDate date,
Status varchar(16),
DeliveryDate date,
Data nvarchar(4000)
)

CREATE TABLE OrderLines (
OrderLineID int,
OrderID int,
ProductID int,
Quantity int,
UnitPrice decimal,
TaxRate decimal
)

CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
WITH ( TYPE = BLOB_STORAGE, LOCATION = 'https://myazureblobstorage.blob.core.windows.net/data');


BULK INSERT Orders
FROM 'orders.bcp'
WITH ( DATA_SOURCE = 'MyAzureBlobStorage',
FORMATFILE = 'orders.fmt',
FORMATFILE_DATA_SOURCE = 'MyAzureBlobStorage',
TABLOCK);


BULK INSERT OrderLines
FROM 'orderlines.bcp'
WITH ( DATA_SOURCE = 'MyAzureBlobStorage',
FORMATFILE = 'orderlines.fmt',
FORMATFILE_DATA_SOURCE = 'MyAzureBlobStorage',
TABLOCK);

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
select c.Name, c.Contact, STRING_AGG(p.Name,',') as Products
from Company c
join Product p on c.CompanyID = p.CompanyID
group by c.CompanyID, c.Name, c.Contact

select c.Name, c.Contact,
'[' + STRING_AGG('"' + STRING_ESCAPE(p.Name) + '"',',') + ']' as Products
from Company c
join Product p on c.CompanyID = p.CompanyID
group by c.CompanyID, c.Name, c.Contact

select c.Name, c.Contact,
JSON_QUERY('[' + STRING_AGG('"' + STRING_ESCAPE(p.Name) + '"',',') + ']') as Products
from Company c
join Product p on c.CompanyID = p.CompanyID
group by c.CompanyID, c.Name, c.Contact
for json path;

WITH CustomerAlsoBuy as (
select p.ProductID, p2.Name, p2.ProductID as RelatedProductID,
ROW_NUMBER() OVER (PARTITION BY p.ProductID ORDER BY count(ol2.OrderID) desc) orders
from Product p
join OrderLines ol1
on p.ProductID = ol1.ProductID
join OrderLines ol2
on ol1.OrderID = ol2.OrderID
and ol1.ProductID <> ol2.ProductID
join Product p2
on ol2.ProductID = p2.ProductID
group by p.ProductID, p.Name, p2.ProductID, p2.Name
)
select ProductID,
'['+STRING_AGG(
CONCAT('{"ProductID":',RelatedProductID,',"Product":"',STRING_ESCAPE(Name,'json'),'"}'),',') + ']' Products
from CustomerAlsoBuy
where orders <= 5
group by ProductID
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcp "select OrderLineID, OrderID, 15 + StockItemId%%14 as ProductID, Quantity, UnitPrice, TaxRate from Sales.OrderLines" queryout .\orderlines.bcp -S "." -d WideWorldImporters -T
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcp "select o.OrderID, OrderDate, case when OrderDate > '2016-04-28' then 'Cancelled' when OrderDate <= '2016-04-28' and OrderDate > '2016-01-01' then 'Delivering' when OrderDate <= '2016-01-01' and OrderDate > '2013-01-10' then 'Delivered' else 'Open' end as Status, DATEADD(day, 3 + (o.OrderID %% 7),OrderDate) as DeliveryDate, ReturnedDeliveryData as Data from Sales.Orders o join Sales.Invoices i on o.OrderId = i.OrderId" queryout .\orders.bcp -S "." -d WideWorldImporters -T
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcp dbo.OrderLines in .\orderlines.bcp -f orderlines.fmt -S 127.0.0.1 -d ProductCatalog -T
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcp dbo.Orders in .\orders.bcp -f orders.fmt -S 127.0.0.1 -d ProductCatalog -T
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcp "select OrderLineID, OrderID, 15 + StockItemId%%14 as ProductID, Quantity, UnitPrice, TaxRate from Sales.OrderLines" queryout .\orderlines.bcp -S "." -d WideWorldImporters -T
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
13.0
6
1 SQLINT 0 4 "" 1 OrderLineID ""
2 SQLINT 0 4 "" 2 OrderID ""
3 SQLINT 1 4 "" 3 ProductID ""
4 SQLINT 0 4 "" 4 Quantity ""
5 SQLDECIMAL 1 19 "" 5 UnitPrice ""
6 SQLDECIMAL 1 19 "" 6 TaxRate ""
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
13.0
5
1 SQLINT 0 4 "" 1 OrderID ""
2 SQLDATE 1 3 "" 2 OrderDate ""
3 SQLCHAR 2 10 "" 3 Status Latin1_General_100_CI_AS
4 SQLDATE 1 3 "" 4 DeliveryDate ""
5 SQLNCHAR 8 0 "" 5 Data Latin1_General_100_CI_AS
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="3.1" jmeter="3.1 r1770033">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">2</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1486984219000</longProp>
<longProp name="ThreadGroup.end_time">1486984219000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="Product List" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">localhost</stringProp>
<stringProp name="HTTPSampler.port">5000</stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path"></stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.concurrentPool">6</stringProp>
</ConfigTestElement>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="REST API Entity Framework" enabled="false">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/ProductCatalog/GetAll</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="REST API FOR JSON" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">api/Product</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<boolProp name="HTTPSampler.monitor">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
<WorkBench guiclass="WorkBenchGui" testclass="WorkBench" testname="WorkBench" enabled="true">
<boolProp name="WorkBench.save">true</boolProp>
</WorkBench>
<hashTree/>
</hashTree>
</jmeterTestPlan>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}\\bin\\www",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
Loading