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
2 changes: 1 addition & 1 deletion test/KingbaseES.BasicTest/KingbaseES.BasicTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace KingbaseES.BasicTest.Migrations
{
public partial class initial : Migration
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down
21 changes: 18 additions & 3 deletions test/KingbaseES.BasicTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,31 @@ static void Main(string[] args)

// get list
var blogs = context.Blogs.ToList();

Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "当前 Blogs 表中条目数:" + blogs.Count);
if (blogs.Any())
{
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "当前 Blogs 表中条目数大于1,进行清理...");
context.Blogs.RemoveRange(blogs);
context.SaveChanges();
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "清理完成!");
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "当前 Blogs 表中条目数:" + blogs.Count);
}
//add
context.Add(new Blog() { Name = "jeffcky" });
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "新增 Blog 实体 值为I love EFCore!");
context.Add(new Blog() { Name = "I love EFCore!" });
var result = context.SaveChanges();

//update
var first = context.Blogs.FirstOrDefault();
first.Name = "jeffcky2";
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "查询结果:" + first.Name);

Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "变更 Blog 实体 值为I love EFCore too!");
first.Name = "I love EFCore too!";
context.SaveChanges();

// get
var testselect = context.Blogs.FirstOrDefault();
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "查询结果:" + testselect.Name);
Console.ReadKey();
}
}
Expand Down