rongguo.jia
2 years ago
commit
8ef014f939
17 changed files with 756 additions and 0 deletions
@ -0,0 +1,265 @@ |
|||
## Ignore Visual Studio temporary files, build results, and |
|||
## files generated by popular Visual Studio add-ons. |
|||
|
|||
# User-specific files |
|||
*.suo |
|||
*.user |
|||
*.userosscache |
|||
*.sln.docstates |
|||
|
|||
# User-specific files (MonoDevelop/Xamarin Studio) |
|||
*.userprefs |
|||
|
|||
# Build results |
|||
[Dd]ebug/ |
|||
[Dd]ebugPublic/ |
|||
[Rr]elease/ |
|||
[Rr]eleases/ |
|||
x64/ |
|||
x86/ |
|||
bld/ |
|||
[Bb]in/ |
|||
[Oo]bj/ |
|||
[Ll]og/ |
|||
|
|||
# Visual Studio 2015 cache/options directory |
|||
.vs/ |
|||
# Uncomment if you have tasks that create the project's static files in wwwroot |
|||
#wwwroot/ |
|||
|
|||
# MSTest test Results |
|||
[Tt]est[Rr]esult*/ |
|||
[Bb]uild[Ll]og.* |
|||
|
|||
# NUNIT |
|||
*.VisualState.xml |
|||
TestResult.xml |
|||
|
|||
# Build Results of an ATL Project |
|||
[Dd]ebugPS/ |
|||
[Rr]eleasePS/ |
|||
dlldata.c |
|||
|
|||
# DNX |
|||
project.lock.json |
|||
artifacts/ |
|||
|
|||
*_i.c |
|||
*_p.c |
|||
*_i.h |
|||
*.ilk |
|||
*.meta |
|||
*.obj |
|||
*.pch |
|||
*.pdb |
|||
*.pgc |
|||
*.pgd |
|||
*.rsp |
|||
*.sbr |
|||
*.tlb |
|||
*.tli |
|||
*.tlh |
|||
*.tmp |
|||
*.tmp_proj |
|||
*.log |
|||
*.vspscc |
|||
*.vssscc |
|||
.builds |
|||
*.pidb |
|||
*.svclog |
|||
*.scc |
|||
|
|||
# Chutzpah Test files |
|||
_Chutzpah* |
|||
|
|||
# Visual C++ cache files |
|||
ipch/ |
|||
*.aps |
|||
*.ncb |
|||
*.opendb |
|||
*.opensdf |
|||
*.sdf |
|||
*.cachefile |
|||
*.VC.db |
|||
*.VC.VC.opendb |
|||
|
|||
# Visual Studio profiler |
|||
*.psess |
|||
*.vsp |
|||
*.vspx |
|||
*.sap |
|||
|
|||
# TFS 2012 Local Workspace |
|||
$tf/ |
|||
|
|||
# Guidance Automation Toolkit |
|||
*.gpState |
|||
|
|||
# ReSharper is a .NET coding add-in |
|||
_ReSharper*/ |
|||
*.[Rr]e[Ss]harper |
|||
*.DotSettings.user |
|||
|
|||
# JustCode is a .NET coding add-in |
|||
.JustCode |
|||
|
|||
# TeamCity is a build add-in |
|||
_TeamCity* |
|||
|
|||
# DotCover is a Code Coverage Tool |
|||
*.dotCover |
|||
|
|||
# NCrunch |
|||
_NCrunch_* |
|||
.*crunch*.local.xml |
|||
nCrunchTemp_* |
|||
|
|||
# MightyMoose |
|||
*.mm.* |
|||
AutoTest.Net/ |
|||
|
|||
# Web workbench (sass) |
|||
.sass-cache/ |
|||
|
|||
# Installshield output folder |
|||
[Ee]xpress/ |
|||
|
|||
# DocProject is a documentation generator add-in |
|||
DocProject/buildhelp/ |
|||
DocProject/Help/*.HxT |
|||
DocProject/Help/*.HxC |
|||
DocProject/Help/*.hhc |
|||
DocProject/Help/*.hhk |
|||
DocProject/Help/*.hhp |
|||
DocProject/Help/Html2 |
|||
DocProject/Help/html |
|||
|
|||
# Click-Once directory |
|||
publish/ |
|||
|
|||
# Publish Web Output |
|||
*.[Pp]ublish.xml |
|||
*.azurePubxml |
|||
# TODO: Comment the next line if you want to checkin your web deploy settings |
|||
# but database connection strings (with potential passwords) will be unencrypted |
|||
*.pubxml |
|||
*.publishproj |
|||
|
|||
# Microsoft Azure Web App publish settings. Comment the next line if you want to |
|||
# checkin your Azure Web App publish settings, but sensitive information contained |
|||
# in these scripts will be unencrypted |
|||
PublishScripts/ |
|||
|
|||
# NuGet Packages |
|||
*.nupkg |
|||
# The packages folder can be ignored because of Package Restore |
|||
**/packages/* |
|||
# except build/, which is used as an MSBuild target. |
|||
!**/packages/build/ |
|||
# Uncomment if necessary however generally it will be regenerated when needed |
|||
#!**/packages/repositories.config |
|||
# NuGet v3's project.json files produces more ignoreable files |
|||
*.nuget.props |
|||
*.nuget.targets |
|||
|
|||
# Microsoft Azure Build Output |
|||
csx/ |
|||
*.build.csdef |
|||
|
|||
# Microsoft Azure Emulator |
|||
ecf/ |
|||
rcf/ |
|||
|
|||
# Windows Store app package directories and files |
|||
AppPackages/ |
|||
BundleArtifacts/ |
|||
Package.StoreAssociation.xml |
|||
_pkginfo.txt |
|||
|
|||
# Visual Studio cache files |
|||
# files ending in .cache can be ignored |
|||
*.[Cc]ache |
|||
# but keep track of directories ending in .cache |
|||
!*.[Cc]ache/ |
|||
|
|||
# Others |
|||
ClientBin/ |
|||
~$* |
|||
*~ |
|||
*.dbmdl |
|||
*.dbproj.schemaview |
|||
*.pfx |
|||
*.publishsettings |
|||
node_modules/ |
|||
orleans.codegen.cs |
|||
|
|||
# Since there are multiple workflows, uncomment next line to ignore bower_components |
|||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) |
|||
#bower_components/ |
|||
|
|||
# RIA/Silverlight projects |
|||
Generated_Code/ |
|||
|
|||
# Backup & report files from converting an old project file |
|||
# to a newer Visual Studio version. Backup files are not needed, |
|||
# because we have git ;-) |
|||
_UpgradeReport_Files/ |
|||
Backup*/ |
|||
UpgradeLog*.XML |
|||
UpgradeLog*.htm |
|||
|
|||
# SQL Server files |
|||
*.mdf |
|||
*.ldf |
|||
|
|||
# Business Intelligence projects |
|||
*.rdl.data |
|||
*.bim.layout |
|||
*.bim_*.settings |
|||
|
|||
# Microsoft Fakes |
|||
FakesAssemblies/ |
|||
|
|||
# GhostDoc plugin setting file |
|||
*.GhostDoc.xml |
|||
|
|||
# Node.js Tools for Visual Studio |
|||
.ntvs_analysis.dat |
|||
|
|||
# Visual Studio 6 build log |
|||
*.plg |
|||
|
|||
# Visual Studio 6 workspace options file |
|||
*.opt |
|||
|
|||
# Visual Studio LightSwitch build output |
|||
**/*.HTMLClient/GeneratedArtifacts |
|||
**/*.DesktopClient/GeneratedArtifacts |
|||
**/*.DesktopClient/ModelManifest.xml |
|||
**/*.Server/GeneratedArtifacts |
|||
**/*.Server/ModelManifest.xml |
|||
_Pvt_Extensions |
|||
|
|||
# Paket dependency manager |
|||
.paket/paket.exe |
|||
paket-files/ |
|||
|
|||
# FAKE - F# Make |
|||
.fake/ |
|||
|
|||
# JetBrains Rider |
|||
.idea/ |
|||
*.sln.iml |
|||
|
|||
# Auth |
|||
src/Win_in.Sfs.Auth.Web/Logs/* |
|||
src/Win_in.Sfs.Auth.Web.Host/Logs/* |
|||
src/Win_in.Sfs.Auth.IdentityServer/Logs/* |
|||
src/Win_in.Sfs.Auth.HttpApi.Host/Logs/* |
|||
src/Win_in.Sfs.Auth.HttpApi.HostWithIds/Logs/* |
|||
src/Win_in.Sfs.Auth.DbMigrator/Logs/* |
|||
src/Win_in.Sfs.Auth.Blazor.Server/Logs/* |
|||
src/Win_in.Sfs.Auth.Blazor.Server.Tiered/Logs/* |
|||
/WmsService/DataExchange/MesFiles/* |
|||
/WmsService/DataExchange/OutputToMes |
|||
/WmsService/DataExchange/Output To Mes |
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using LinqToDB; |
|||
using LinqToDB.Configuration; |
|||
using LinqToDB.Data; |
|||
using SyBaseTestWebApp; |
|||
|
|||
public class AppDataConnection : DataConnection |
|||
{ |
|||
public AppDataConnection(LinqToDBConnectionOptions<AppDataConnection> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
|
|||
public ITable<Users> Users => this.GetTable<Users>(); |
|||
|
|||
public ITable<Part> Part => this.GetTable<Part>(); |
|||
|
|||
} |
@ -0,0 +1,7 @@ |
|||
namespace SyBaseTestWebApp.Controllers |
|||
{ |
|||
public class Class1 |
|||
{ |
|||
|
|||
} |
|||
} |
@ -0,0 +1,73 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using LinqToDB; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace SyBaseTestWebApp.Controllers |
|||
{ |
|||
[ApiController] |
|||
[Route("[controller]")]
|
|||
public class WeatherForecastController : ControllerBase |
|||
{ |
|||
|
|||
private readonly AppDataConnection _connection; |
|||
private readonly ILogger<WeatherForecastController> _logger; |
|||
|
|||
public WeatherForecastController( |
|||
AppDataConnection connection |
|||
,ILogger<WeatherForecastController> logger) |
|||
{ |
|||
_connection = connection; |
|||
_logger = logger; |
|||
} |
|||
|
|||
|
|||
|
|||
[HttpGet] |
|||
public Task<Part[]> ListUser() |
|||
{ |
|||
return _connection.Part.ToArrayAsync(); |
|||
} |
|||
|
|||
[HttpGet("{id}")] |
|||
public async Task<Part?> GetUser(int id) |
|||
{ |
|||
|
|||
var parts =await _connection.Part.Where(p => p.Id == id).ToListAsync(); |
|||
|
|||
return parts[0]; |
|||
|
|||
// return _connection.Part.FirstOrDefaultAsync(person => person.Id == id);
|
|||
} |
|||
|
|||
[HttpDelete("{id}")] |
|||
public Task<int> DeleteUser(int id) |
|||
{ |
|||
return _connection.Part.Where(person => person.Id == id).DeleteAsync(); |
|||
} |
|||
|
|||
[HttpPut] |
|||
public Task<int> UpdateUser(Part person) |
|||
{ |
|||
return _connection.UpdateAsync(person); |
|||
} |
|||
|
|||
[HttpPatch("{id}/new-name")] |
|||
public Task<int> UpdateUserName(int id, string newName) |
|||
{ |
|||
return _connection.Part.Where(person => person.Id == id) |
|||
.Set(person => person.Name, newName) |
|||
.UpdateAsync(); |
|||
} |
|||
|
|||
[HttpPost] |
|||
public Task<int> InsertUser(Part person) |
|||
{ |
|||
return _connection.InsertAsync(person); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace SyBaseTestWebApp |
|||
{ |
|||
public class Program |
|||
{ |
|||
public static void Main(string[] args) |
|||
{ |
|||
CreateHostBuilder(args).Build().Run(); |
|||
} |
|||
|
|||
public static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
{ |
|||
"$schema": "http://json.schemastore.org/launchsettings.json", |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:14699", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"launchUrl": "swagger", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"SyBaseTestWebApp": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": "true", |
|||
"launchBrowser": true, |
|||
"launchUrl": "swagger", |
|||
"applicationUrl": "http://localhost:5000", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,74 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using LinqToDB.AspNet; |
|||
using LinqToDB.AspNet.Logging; |
|||
using LinqToDB.Configuration; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.OpenApi.Models; |
|||
using WatchDog; |
|||
|
|||
namespace SyBaseTestWebApp |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public Startup(IConfiguration configuration) |
|||
{ |
|||
Configuration = configuration; |
|||
} |
|||
|
|||
public IConfiguration Configuration { get; } |
|||
|
|||
// This method gets called by the runtime. Use this method to add services to the container.
|
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddLinqToDBContext<AppDataConnection>((provider, options) => { |
|||
options |
|||
//will configure the AppDataConnection to use
|
|||
//sqite with the provided connection string
|
|||
//there are methods for each supported database
|
|||
.UseAse(Configuration.GetConnectionString("Default")) |
|||
//default logging will log everything using the ILoggerFactory configured in the provider
|
|||
.UseDefaultLogging(provider); |
|||
}); |
|||
|
|||
services.AddWatchDogServices(); |
|||
|
|||
services.AddControllers(); |
|||
services.AddSwaggerGen(c => |
|||
{ |
|||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "SyBaseTestWebApp", Version = "v1" }); |
|||
}); |
|||
} |
|||
|
|||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|||
{ |
|||
if (env.IsDevelopment()) |
|||
{ |
|||
app.UseDeveloperExceptionPage(); |
|||
app.UseSwagger(); |
|||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "SyBaseTestWebApp v1")); |
|||
} |
|||
app.UseWatchDog(opt => |
|||
{ |
|||
opt.WatchPageUsername = "admin"; opt.WatchPagePassword = "Qwerty@123"; |
|||
}); |
|||
app.UseRouting(); |
|||
|
|||
app.UseAuthorization(); |
|||
|
|||
app.UseEndpoints(endpoints => |
|||
{ |
|||
endpoints.MapControllers(); |
|||
}); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AdoNetCore.AseClient" Version="0.19.2" /> |
|||
<PackageReference Include="linq2db.AspNet" Version="4.3.0" /> |
|||
<PackageReference Include="linq2db.Sybase" Version="4.3.0" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> |
|||
<PackageReference Include="WatchDog.NET" Version="1.3.2" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -0,0 +1,36 @@ |
|||
using LinqToDB.Mapping; |
|||
|
|||
namespace SyBaseTestWebApp |
|||
{ |
|||
public class Users |
|||
{ |
|||
[PrimaryKey] |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
public string Dept { get; set; } |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return $"{Id},{Name},{Dept}"; |
|||
} |
|||
} |
|||
|
|||
public class Part |
|||
{ |
|||
[PrimaryKey] |
|||
[Identity] |
|||
public int Id { get; set; } |
|||
public string Code { get; set; } |
|||
public string Name { get; set; } |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return $"Id:{Id},Code:{Code},Name:{Name}"; |
|||
} |
|||
|
|||
public void SetId(int id) |
|||
{ |
|||
Id = id; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
using System; |
|||
|
|||
namespace SyBaseTestWebApp |
|||
{ |
|||
public class WeatherForecast |
|||
{ |
|||
public DateTime Date { get; set; } |
|||
|
|||
public int TemperatureC { get; set; } |
|||
|
|||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); |
|||
|
|||
public string Summary { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft": "Warning", |
|||
"Microsoft.Hosting.Lifetime": "Information" |
|||
} |
|||
}, |
|||
"AllowedHosts": "*", |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=dev.ccwin-in.com; Port=15000; Database=TYRP; Uid=sa; Pwd=Microsoft2008;Charset=iso_1;" |
|||
} |
|||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,31 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 17 |
|||
VisualStudioVersion = 17.3.32922.545 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SybaseTest", "SybaseTest\SybaseTest.csproj", "{000896B3-2A75-4C73-9D53-00AFF85C250A}" |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyBaseTestWebApp", "SyBaseTestWebApp\SyBaseTestWebApp.csproj", "{13CBB564-B3AC-4801-AE1D-EE87DEFDB4BA}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{000896B3-2A75-4C73-9D53-00AFF85C250A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{000896B3-2A75-4C73-9D53-00AFF85C250A}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{000896B3-2A75-4C73-9D53-00AFF85C250A}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{000896B3-2A75-4C73-9D53-00AFF85C250A}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{13CBB564-B3AC-4801-AE1D-EE87DEFDB4BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{13CBB564-B3AC-4801-AE1D-EE87DEFDB4BA}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{13CBB564-B3AC-4801-AE1D-EE87DEFDB4BA}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{13CBB564-B3AC-4801-AE1D-EE87DEFDB4BA}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {7895A86A-CF05-4A3C-85D6-2250E48A3E25} |
|||
EndGlobalSection |
|||
EndGlobal |
@ -0,0 +1,130 @@ |
|||
using System; |
|||
using System.Data; |
|||
using System.Linq; |
|||
using AdoNetCore.AseClient; |
|||
using Dapper; |
|||
|
|||
namespace SybaseTest |
|||
{ |
|||
internal class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
Console.WriteLine("Hello World!"); |
|||
|
|||
Delete(); |
|||
|
|||
Add(); |
|||
|
|||
Query(); |
|||
|
|||
Update(); |
|||
|
|||
Query(); |
|||
} |
|||
|
|||
private static void Delete() |
|||
{ |
|||
using (IDbConnection conn = SybaseConn) |
|||
{ |
|||
Users user = new Users |
|||
{ |
|||
Id = 1 |
|||
}; |
|||
string sqlCommandText = @"DELETE FROM Users WHERE Id=@Id"; |
|||
int result = conn.Execute(sqlCommandText, user); |
|||
Console.WriteLine(result); |
|||
user = new Users |
|||
{ |
|||
Id = 2 |
|||
}; |
|||
sqlCommandText = @"DELETE FROM Users WHERE Id=@Id"; |
|||
result = conn.Execute(sqlCommandText, user); |
|||
Console.WriteLine(result); |
|||
} |
|||
} |
|||
|
|||
private static void Update() |
|||
{ |
|||
using (IDbConnection conn = SybaseConn) |
|||
{ |
|||
Users user = new Users |
|||
{ |
|||
Id = 1, |
|||
Name = "CNKI", |
|||
Dept = "HR" |
|||
}; |
|||
string sqlCommandText = @"UPDATE Users SET Dept=@Dept WHERE Id=@Id"; |
|||
int result = conn.Execute(sqlCommandText, user); |
|||
Console.WriteLine(result); |
|||
} |
|||
} |
|||
|
|||
private static void Query() |
|||
{ |
|||
using (IDbConnection conn = SybaseConn) |
|||
{ |
|||
string sqlCommandText = @"SELECT * FROM Users"; |
|||
var users = conn.Query<Users>(sqlCommandText).ToList(); |
|||
foreach (var user in users) |
|||
{ |
|||
Console.WriteLine(user); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
private static void Add() |
|||
{ |
|||
using (IDbConnection conn = SybaseConn) |
|||
{ |
|||
Users user1 = new Users |
|||
{ |
|||
Id = 1, |
|||
Name = "CNKI", |
|||
Dept = "Sale" |
|||
}; |
|||
string sqlCommandText = @"INSERT INTO Users(Id,Name,Dept)VALUES(@Id,@Name,@Dept)"; |
|||
int result = conn.Execute(sqlCommandText, user1); |
|||
Console.WriteLine(result); |
|||
Users user2 = new Users |
|||
{ |
|||
Id = 2, |
|||
Name = "MSDN", |
|||
Dept = "Sale" |
|||
}; |
|||
sqlCommandText = @"INSERT INTO Users(Id,Name,Dept)VALUES(@Id,@Name,@Dept)"; |
|||
result = conn.Execute(sqlCommandText, user2); |
|||
Console.WriteLine(result); |
|||
} |
|||
} |
|||
|
|||
public static IDbConnection SybaseConn |
|||
{ |
|||
get |
|||
{ |
|||
try |
|||
{ |
|||
return new AseConnection("Data Source=dev.ccwin-in.com; Port=15000; Database=TYRP; Uid=sa; Pwd=Microsoft2008;Charset=iso_1;"); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
internal class Users |
|||
{ |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
public string Dept { get; set; } |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return $"{Id},{Name},{Dept}"; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AdoNetCore.AseClient" Version="0.19.2" /> |
|||
<PackageReference Include="Dapper" Version="2.0.123" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
Loading…
Reference in new issue