blob: 11cda548ec529f8104e3f490846b990ac84a109c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//
// System.Data.RelatedDataView
//
// Author:
// Konstantin Triger (kostat@mainsoft.com)
//
using System;
using System.Collections;
using Mono.Data.SqlExpressions;
using System.Data.Common;
namespace System.Data
{
/// <summary>
/// Summary description for RelatedDataView.
/// </summary>
internal class RelatedDataView : DataView, IExpression
{
#region Fields
object[] _keyValues;
DataColumn[] _columns;
#endregion // Fields
#region Constructors
internal RelatedDataView(DataColumn[] relatedColumns,object[] keyValues)
{
dataTable = relatedColumns[0].Table;
rowState = DataViewRowState.CurrentRows;
_columns = relatedColumns;
_keyValues = keyValues;
Open();
}
#endregion // Constructors
#region Methods
internal override IExpression FilterExpression {
get {
return this;
}
}
#endregion // Methods
public override bool Equals(object obj)
{
if (!(obj is RelatedDataView)) {
if (base.FilterExpression == null)
return false;
return base.FilterExpression.Equals (obj);
}
RelatedDataView other = (RelatedDataView) obj;
if (_columns.Length != other._columns.Length)
return false;
for (int i = 0; i < _columns.Length; i++)
if (!_columns[i].Equals(other._columns [i]) ||
!_keyValues[i].Equals(other._keyValues [i]))
return false;
if (!other.FilterExpression.Equals (base.FilterExpression))
return false;
return true;
}
public override int GetHashCode()
{
int hashCode = 0;
for (int i = 0; i < _columns.Length; i++) {
hashCode ^= _columns [i].GetHashCode ();
hashCode ^= _keyValues [i].GetHashCode ();
}
if (base.FilterExpression != null)
hashCode ^= base.FilterExpression.GetHashCode ();
return hashCode;
}
#region IExpression Members
public object Eval(DataRow row) {
return EvalBoolean(row);
}
public bool EvalBoolean(DataRow row) {
for (int i = 0; i < _columns.Length; i++)
if (!row[_columns[i]].Equals(_keyValues[i]))
return false;
IExpression filter = base.FilterExpression;
return filter != null ? filter.EvalBoolean(row) : true;
}
public bool DependsOn(DataColumn other) {
for (int i = 0; i < _columns.Length; i++)
if (_columns[i] == other)
return true;
IExpression filter = base.FilterExpression;
return filter != null ? filter.DependsOn(other) : false;
}
void IExpression.ResetExpression()
{
}
#endregion
}
}
|