Mercurial > pub > bltoolkit
comparison Source/Data/Linq/Builder/SqlInfo.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.Linq; | |
4 using System.Reflection; | |
5 using BLToolkit.Reflection; | |
6 | |
7 namespace BLToolkit.Data.Linq.Builder | |
8 { | |
9 using Data.Sql; | |
10 | |
11 public class SqlInfo | |
12 { | |
13 public ISqlExpression Sql; | |
14 public SqlQuery Query; | |
15 public int Index = -1; | |
16 public List<MemberInfo> Members = new List<MemberInfo>(); | |
17 | |
18 public SqlInfo() | |
19 { | |
20 } | |
21 | |
22 public SqlInfo(MemberInfo mi) | |
23 { | |
24 Members.Add(mi); | |
25 } | |
26 | |
27 public SqlInfo(IEnumerable<MemberInfo> mi) | |
28 { | |
29 Members.AddRange(mi); | |
30 } | |
31 | |
32 public SqlInfo Clone() | |
33 { | |
34 return new SqlInfo(Members) { Sql = Sql, Query = Query, Index = Index }; | |
35 } | |
36 | |
37 public SqlInfo Clone(MemberInfo mi) | |
38 { | |
39 var info = Clone(); | |
40 if (Members.Count == 0 || Members[0] != mi) | |
41 info.Members.Insert(0, mi); | |
42 else | |
43 { | |
44 | |
45 } | |
46 return info; | |
47 } | |
48 | |
49 public bool CompareMembers(SqlInfo info) | |
50 { | |
51 return Members.Count == info.Members.Count && !Members.Where((t, i) => !TypeHelper.Equals(t, info.Members[i])).Any(); | |
52 } | |
53 | |
54 public bool CompareLastMember(SqlInfo info) | |
55 { | |
56 return | |
57 Members.Count > 0 && info.Members.Count > 0 && | |
58 TypeHelper.Equals(Members[Members.Count - 1], info.Members[info.Members.Count - 1]); | |
59 } | |
60 } | |
61 } |