Skip to content

Commit 9432483

Browse files
Merge pull request #1 from adessoTurkey-dotNET/feature/oracle
OracleSql SP and Func, MsSql Func, MySql Func, PostgreSql SP added.
2 parents 204a510 + 323c855 commit 9432483

20 files changed

+1072
-134
lines changed

BctSP.sln

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32210.238
5+
MinimumVisualStudioVersion = 10.0.40219.1
36
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4B99FA8B-72A1-4CD7-A55D-150641DF1FCC}"
47
EndProject
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BctSP", "src\BctSP\BctSP.csproj", "{EE754FA4-D9D1-4E00-B85C-74840E621F3E}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BctSP", "src\BctSP\BctSP.csproj", "{EE754FA4-D9D1-4E00-B85C-74840E621F3E}"
69
EndProject
710
Global
811
GlobalSection(SolutionConfigurationPlatforms) = preSolution
912
Debug|Any CPU = Debug|Any CPU
1013
Release|Any CPU = Release|Any CPU
1114
EndGlobalSection
12-
GlobalSection(NestedProjects) = preSolution
13-
{EE754FA4-D9D1-4E00-B85C-74840E621F3E} = {4B99FA8B-72A1-4CD7-A55D-150641DF1FCC}
14-
EndGlobalSection
1515
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1616
{EE754FA4-D9D1-4E00-B85C-74840E621F3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1717
{EE754FA4-D9D1-4E00-B85C-74840E621F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1818
{EE754FA4-D9D1-4E00-B85C-74840E621F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1919
{EE754FA4-D9D1-4E00-B85C-74840E621F3E}.Release|Any CPU.Build.0 = Release|Any CPU
2020
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(NestedProjects) = preSolution
25+
{EE754FA4-D9D1-4E00-B85C-74840E621F3E} = {4B99FA8B-72A1-4CD7-A55D-150641DF1FCC}
26+
EndGlobalSection
27+
GlobalSection(ExtensibilityGlobals) = postSolution
28+
SolutionGuid = {A7B66724-D32B-40A5-BDD2-364C5AFF56B8}
29+
EndGlobalSection
2130
EndGlobal

README.md

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,36 @@ builder.Services.AddBctSp((x) =>
2525
```
2626

2727
- Create a request that inherits from the BctSpBaseRequest. The generic argument of the BctSpBaseRequest should be the response type of the request that inherits BctSpBaseResponse.
28+
- The request should have 2 class attributes, sp/function name and command type.
2829

2930
```cs
31+
[BctSpAttribute("GetProductsByPrice", BctSP.Enums.BctSpCommandType.StoredProcedure)]
3032
public class GetProductsByPriceRequest : BctSpBaseRequest<GetProductsByPriceResponse>
3133
{
32-
public GetProductsByPriceRequest(string bctSpName) : base(bctSpName)
33-
{
34-
}
3534

3635
public decimal ProductPrice { get; set; }
3736

3837
}
3938
```
39+
40+
_Customized Usage_
41+
The database configuration can be overridden and customized for each request if needed.
42+
43+
```cs
44+
[BctSpAttribute("GetProductsByPrice", BctSP.Enums.BctSpCommandType.StoredProcedure,"CustomDatabases:ConnectionString",BctSP.Enums.BctSpDatabaseType.MsSql))]
45+
public class GetProductsByPriceRequest : BctSpBaseRequest<GetProductsByPriceResponse>
46+
{
47+
public decimal ProductPrice { get; set; }
48+
}
49+
50+
//[BctSpAttribute("GetProductsByPrice", BctSP.Enums.BctSpCommandType.StoredProcedure,"Server=...",,BctSP.Enums.BctSpDatabaseType.MsSql))]
51+
//public class GetProductsByPriceRequest : BctSpBaseRequest<GetProductsByPriceResponse>
52+
//{
53+
// public decimal ProductPrice { get; set; }
54+
//}
55+
56+
```
57+
4058
- Create a response that inherits from the BctSpBaseResponse.
4159

4260
```cs
@@ -84,54 +102,19 @@ _Sample Usage_
84102
```cs
85103
public List<GetProductsByPriceResponse> GetProductsByPrice()
86104
{
87-
var response = _sampleSp.GetProductsByPrice(new GetProductsByPriceRequest("yourSPname") { ProductPrice = 100 });
105+
var response = _sampleSp.GetProductsByPrice(new GetProductsByPriceRequest{ ProductPrice = 100 });
88106

89107
return response;
90108
}
91109

92110
public async Task<List<GetProductsByPriceResponse>> GetProductsByPriceAsync()
93111
{
94-
var response = await _sampleSp.GetProductsByPriceAsync(new GetProductsByPriceRequest("yourSPname") { ProductPrice = 100 });
112+
var response = await _sampleSp.GetProductsByPriceAsync(new GetProductsByPriceRequest{ ProductPrice = 100 });
95113

96114
return response;
97115
}
98116
```
99117

100-
101-
_Customized Usage_
102-
The database configuration can be overridden and customized for each request if needed.
103-
104-
```cs
105-
public List<GetProductsByPriceResponse> GetProductsByPrice()
106-
{
107-
var response = _sampleSp.GetProductsByPrice(
108-
new GetProductsByPriceRequest("yourSPname",
109-
"CustomDatabases:ConnectionString",
110-
BctSpDatabaseType.MsSql) { ProductPrice = 100 });
111-
112-
// var response = _sampleSp.GetProductsByPrice(
113-
// new GetProductsByPriceRequest("yourSPname",
114-
// "Server=...",
115-
// BctSpDatabaseType.MsSql) { ProductPrice = 100 });
116-
117-
return response;
118-
}
119-
120-
public async Task<List<GetProductsByPriceResponse>> GetProductsByPriceAsync()
121-
{
122-
var response = await _sampleSp.GetProductsByPriceAsync(
123-
new GetProductsByPriceRequest("yourSPname",
124-
"CustomDatabases:ConnectionString",
125-
BctSpDatabaseType.MsSql) { ProductPrice = 100 });
126-
127-
// var response = await _sampleSp.GetProductsByPriceAsync(
128-
// new GetProductsByPriceRequest("yourSPname",
129-
// "Server=...",
130-
// BctSpDatabaseType.MsSql) { ProductPrice = 100 });
131-
132-
return response;
133-
}
134-
```
135118
------------
136119
**Contact Me:** &nbsp; - ***[LinkedIn](https://tr.linkedin.com/in/bariscantanriverdi)*** &nbsp; - &nbsp; ***[Mail](mailto:mail@[email protected]?subject=BctSP)***
137120
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using BctSP.Enums;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace BctSP.Attributes
7+
{
8+
/// <summary>
9+
///
10+
/// </summary>
11+
[AttributeUsage(AttributeTargets.Class , AllowMultiple = true)]
12+
public class BctSpAttribute : Attribute
13+
{
14+
/// <summary>
15+
///
16+
/// </summary>
17+
public BctSpAttribute(string bctSpName, BctSpCommandType bctSpCommandType)
18+
{
19+
BctSpName = bctSpName;
20+
BctSpCommandType = bctSpCommandType;
21+
}
22+
23+
/// <summary>
24+
///
25+
/// </summary>
26+
public BctSpAttribute(string bctSpName, BctSpCommandType bctSpCommandType, string bctSpConnectionStringOrConfigurationPath, BctSpDatabaseType bctSpDatabaseType)
27+
{
28+
BctSpName = bctSpName;
29+
BctSpCommandType = bctSpCommandType;
30+
BctSpConnectionStringOrConfigurationPath = bctSpConnectionStringOrConfigurationPath;
31+
BctSpDatabaseType = bctSpDatabaseType;
32+
}
33+
34+
/// <summary>
35+
/// -MsSql, MySql, PostgreSql, Oracle -> Stored procedure, -MsSql, MySql, PostgreSql, Oracle -> function- Name
36+
/// </summary>
37+
public string BctSpName { get; }
38+
39+
/// <summary>
40+
/// Custom database connection string directly or configuration path to connection string. -Use this if you want override global configuration for the request.
41+
/// </summary>
42+
public string BctSpConnectionStringOrConfigurationPath { get; }
43+
44+
/// <summary>
45+
/// Custom database type. -Use this if you want override global configuration for the request.
46+
/// </summary>
47+
public BctSpDatabaseType BctSpDatabaseType { get; }
48+
49+
/// <summary>
50+
/// Custom command type. -Use this if you want override global configuration for the request.
51+
/// </summary>
52+
public BctSpCommandType BctSpCommandType { get; }
53+
54+
}
55+
}

src/BctSP/BctSP.csproj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" />
2424
<None Include="..\..\logo.png" Pack="true" PackagePath="\" />
2525

26-
<PackageReference Include="ImpromptuInterface" Version="7.0.1"/>
27-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0"/>
28-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4"/>
29-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0"/>
30-
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0"/>
31-
<PackageReference Include="MySql.Data" Version="8.0.33"/>
32-
<PackageReference Include="Npgsql" Version="7.0.4"/>
33-
<PackageReference Include="System.Data.SqlClient" Version="4.8.5"/>
26+
<PackageReference Include="ImpromptuInterface" Version="7.0.1" />
27+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
28+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
29+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
30+
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
31+
<PackageReference Include="MySql.Data" Version="8.0.33" />
32+
<PackageReference Include="Npgsql" Version="7.0.4" />
33+
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.100" />
34+
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
3435
</ItemGroup>
3536

3637
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using BctSP.Enums;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace BctSP
7+
{
8+
/// <summary>
9+
///
10+
/// </summary>
11+
public class BctSpConfiguration
12+
{
13+
/// <summary>
14+
/// -MsSql, MySql -> Stored procedure, PostgreSql -> function- Name
15+
/// </summary>
16+
public string BctSpName { get; set; }
17+
18+
/// <summary>
19+
/// Custom database connection string directly or configuration path to connection string. -Use this if you want override global configuration for the request.
20+
/// </summary>
21+
public string BctSpConnectionStringOrConfigurationPath { get; set; }
22+
23+
/// <summary>
24+
/// Custom database type. -Use this if you want override global configuration for the request.
25+
/// </summary>
26+
public BctSpDatabaseType? BctSpDatabaseType { get; set; }
27+
28+
/// <summary>
29+
/// Custom command type. -Use this if you want override global configuration for the request.
30+
/// </summary>
31+
public BctSpCommandType BctSpCommandType { get; set; }
32+
}
33+
}

src/BctSP/BctSpOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using BctSP.Enums;
2+
13
namespace BctSP
24
{
35
/// <summary>

0 commit comments

Comments
 (0)