mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
完成延时加载开发与测试,ICollection集合待支持
This commit is contained in:
@ -10,28 +10,39 @@ namespace FreeSql.Tests.MySql {
|
||||
ISelect<Topic> select => g.mysql.Select<Topic>();
|
||||
|
||||
[Table(Name = "tb_topic")]
|
||||
class Topic {
|
||||
public class Topic {
|
||||
[Column(IsIdentity = true, IsPrimary = true)]
|
||||
public int Id { get; set; }
|
||||
public int Clicks { get; set; }
|
||||
public int TestTypeInfoGuid { get; set; }
|
||||
public TestTypeInfo Type { get; set; }
|
||||
|
||||
public int TypeGuid { get; set; }
|
||||
public virtual TestTypeInfo Type { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
class TestTypeInfo {
|
||||
public class TestTypeInfo {
|
||||
[Column(IsIdentity = true)]
|
||||
public int Guid { get; set; }
|
||||
public int ParentId { get; set; }
|
||||
public TestTypeParentInfo Parent { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
class TestTypeParentInfo {
|
||||
public class TestTypeParentInfo {
|
||||
[Column(IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<TestTypeInfo> Types { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Lazy() {
|
||||
Topic t = g.mysql.Select<Topic>(2).ToOne();
|
||||
Topic tz = g.mysql.Select<Topic>(2).ToOne();
|
||||
var tzType = tz.Type;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToList() {
|
||||
var t0 = select.Limit(50).ToList();
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
|
||||
@ -11,7 +12,7 @@ public class g {
|
||||
|
||||
.UseMonitorCommand(
|
||||
cmd => {
|
||||
Console.WriteLine(cmd.CommandText);
|
||||
Trace.WriteLine(cmd.CommandText);
|
||||
}, //监听SQL命令对象,在执行前
|
||||
(cmd, traceLog) => {
|
||||
Console.WriteLine(traceLog);
|
||||
|
Reference in New Issue
Block a user