U:调整所有代码格式
This commit is contained in:
1 parent
d133bacf55
commit
155b67e831
342 files changed
+9431
-9868
No files matched your search
@@ -118,10 +118,7 @@ public class _06_CustomEntityTests
|
||||
// 列出所有地区
|
||||
var allRegions = await regions.ToListAsync();
|
||||
Console.WriteLine($"\n所有地区:");
|
||||
foreach (var region in allRegions)
|
||||
{
|
||||
Console.WriteLine($" [{region.Code}] {region.Name}");
|
||||
}
|
||||
foreach (var region in allRegions) Console.WriteLine($" [{region.Code}] {region.Name}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -155,7 +152,7 @@ public class _06_CustomEntityTests
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
Console.WriteLine($" ID: {tag.Id}, Name: {tag.Name}, Color: {tag.Color}");
|
||||
Assert.IsTrue(tag.Id > 0); // 自增 Id
|
||||
Assert.IsTrue(tag.Id > 0); // 自增 Id
|
||||
}
|
||||
|
||||
// 查询
|
||||
@@ -306,8 +303,7 @@ public class _06_CustomEntityTests
|
||||
var repo = db.Repository<CustomProduct>();
|
||||
|
||||
// 添加测试数据
|
||||
for (int i = 1; i <= 20; i++)
|
||||
{
|
||||
for (var i = 1; i <= 20; i++)
|
||||
await repo.AddAsync(new CustomProduct
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
@@ -315,7 +311,6 @@ public class _06_CustomEntityTests
|
||||
Price = i * 100m,
|
||||
CreatedDate = DateTime.UtcNow.AddDays(-i)
|
||||
});
|
||||
}
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
Console.WriteLine("=== 自定义实体的查询 ===\n");
|
||||
@@ -326,7 +321,7 @@ public class _06_CustomEntityTests
|
||||
|
||||
// 2. 使用业务属性查询
|
||||
var veryExpensive = await repo.Query()
|
||||
.Where(p => p.IsExpensive) // 使用计算属性
|
||||
.Where(p => p.IsExpensive) // 使用计算属性
|
||||
.ToListAsync();
|
||||
Console.WriteLine($"2. 使用 IsExpensive 属性: {veryExpensive.Count} 个");
|
||||
|
||||
@@ -382,4 +377,4 @@ public class _06_CustomEntityTests
|
||||
Console.WriteLine(" 你可以完全自定义,仍然享受仓储模式的便利");
|
||||
Console.WriteLine(" 灵活性和便利性可以兼得!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user