Skip to content

Commit 33230bb

Browse files
committed
Fix Clone() in Query.
1 parent d20e930 commit 33230bb

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

QueryBuilder/Include.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,16 @@ public class Include
77
public string ForeignKey { get; set; }
88
public string LocalKey { get; set; }
99
public bool IsMany { get; set; }
10+
11+
public Include Clone()
12+
{
13+
var clone = new Include();
14+
clone.Name = this.Name;
15+
clone.Query = this.Query.Clone();
16+
clone.ForeignKey = this.ForeignKey;
17+
clone.LocalKey = this.LocalKey;
18+
clone.IsMany = this.IsMany;
19+
return clone;
20+
}
1021
}
1122
}

QueryBuilder/Query.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ internal int GetLimit(string engineCode = null)
5151
public override Query Clone()
5252
{
5353
var clone = base.Clone();
54-
clone.Parent = Parent;
54+
clone.Parent = (Parent as Query)?.Clone();
5555
clone.QueryAlias = QueryAlias;
5656
clone.IsDistinct = IsDistinct;
5757
clone.Method = Method;
58-
clone.Includes = Includes;
59-
clone.Variables = Variables;
58+
clone.Includes = Includes.Select(i => i.Clone()).ToList();
59+
clone.Variables = Variables.ToDictionary();
6060
return clone;
6161
}
6262

0 commit comments

Comments
 (0)