0
|
1 using System;
|
|
2 using System.Data;
|
|
3 using System.Data.Linq;
|
|
4
|
|
5 using BLToolkit.DataAccess;
|
|
6
|
|
7 namespace Data.Linq.Model
|
|
8 {
|
|
9 public class LinqDataTypes : IEquatable<LinqDataTypes>, IComparable
|
|
10 {
|
|
11 public int ID;
|
|
12 public decimal MoneyValue;
|
|
13 public DateTime DateTimeValue;
|
|
14 public bool BoolValue;
|
|
15 public Guid GuidValue;
|
|
16 public Binary BinaryValue;
|
|
17 public short SmallIntValue;
|
|
18
|
|
19 public override bool Equals(object obj)
|
|
20 {
|
|
21 return Equals(obj as LinqDataTypes);
|
|
22 }
|
|
23
|
|
24 public bool Equals(LinqDataTypes other)
|
|
25 {
|
|
26 if (ReferenceEquals(null, other)) return false;
|
|
27 if (ReferenceEquals(this, other)) return true;
|
|
28 return
|
|
29 other.ID == ID &&
|
|
30 other.MoneyValue == MoneyValue &&
|
|
31 other.BoolValue == BoolValue &&
|
|
32 other.GuidValue == GuidValue &&
|
|
33 other.SmallIntValue == SmallIntValue &&
|
|
34 other.DateTimeValue.Date == DateTimeValue.Date &&
|
|
35 other.DateTimeValue.Hour == DateTimeValue.Hour &&
|
|
36 other.DateTimeValue.Minute == DateTimeValue.Minute &&
|
|
37 other.DateTimeValue.Second == DateTimeValue.Second;
|
|
38 }
|
|
39
|
|
40 public override int GetHashCode()
|
|
41 {
|
|
42 return ID;
|
|
43 }
|
|
44
|
|
45 public int CompareTo(object obj)
|
|
46 {
|
|
47 return ID - ((LinqDataTypes)obj).ID;
|
|
48 }
|
|
49
|
|
50 public static bool operator == (LinqDataTypes left, LinqDataTypes right)
|
|
51 {
|
|
52 return Equals(left, right);
|
|
53 }
|
|
54
|
|
55 public static bool operator != (LinqDataTypes left, LinqDataTypes right)
|
|
56 {
|
|
57 return !Equals(left, right);
|
|
58 }
|
|
59
|
|
60 public override string ToString()
|
|
61 {
|
|
62 return string.Format("{{{0,2}, {1,7}, {2}, {3,5}, {4}, {5}}}", ID, MoneyValue, DateTimeValue, BoolValue, GuidValue, SmallIntValue);
|
|
63 }
|
|
64 }
|
|
65
|
|
66 [TableName("LinqDataTypes")]
|
|
67 public class LinqDataTypes2 : IEquatable<LinqDataTypes2>, IComparable
|
|
68 {
|
|
69 [PrimaryKey]
|
|
70 public int ID;
|
|
71 public decimal MoneyValue;
|
|
72 public DateTime? DateTimeValue;
|
|
73 [DbType(DbType.DateTime2)]
|
|
74 public DateTime? DateTimeValue2;
|
|
75 public bool? BoolValue;
|
|
76 public Guid? GuidValue;
|
|
77 public short? SmallIntValue;
|
|
78 public int? IntValue;
|
|
79 public long? BigIntValue;
|
|
80
|
|
81 public override bool Equals(object obj)
|
|
82 {
|
|
83 return Equals(obj as LinqDataTypes2);
|
|
84 }
|
|
85
|
|
86 public bool Equals(LinqDataTypes2 other)
|
|
87 {
|
|
88 if (ReferenceEquals(null, other)) return false;
|
|
89 if (ReferenceEquals(this, other)) return true;
|
|
90 return
|
|
91 other.ID == ID &&
|
|
92 other.MoneyValue == MoneyValue &&
|
|
93 other.BoolValue == BoolValue &&
|
|
94 other.GuidValue == GuidValue &&
|
|
95 other.DateTimeValue.Value.Date == DateTimeValue.Value.Date &&
|
|
96 other.DateTimeValue.Value.Hour == DateTimeValue.Value.Hour &&
|
|
97 other.DateTimeValue.Value.Minute == DateTimeValue.Value.Minute &&
|
|
98 other.DateTimeValue.Value.Second == DateTimeValue.Value.Second;
|
|
99 }
|
|
100
|
|
101 public override int GetHashCode()
|
|
102 {
|
|
103 return ID;
|
|
104 }
|
|
105
|
|
106 public int CompareTo(object obj)
|
|
107 {
|
|
108 return ID - ((LinqDataTypes2)obj).ID;
|
|
109 }
|
|
110
|
|
111 public static bool operator ==(LinqDataTypes2 left, LinqDataTypes2 right)
|
|
112 {
|
|
113 return Equals(left, right);
|
|
114 }
|
|
115
|
|
116 public static bool operator !=(LinqDataTypes2 left, LinqDataTypes2 right)
|
|
117 {
|
|
118 return !Equals(left, right);
|
|
119 }
|
|
120
|
|
121 public override string ToString()
|
|
122 {
|
|
123 return string.Format("{{{0,2}, {1,7}, {2}, {3,5}, {4}}}", ID, MoneyValue, DateTimeValue, BoolValue, GuidValue);
|
|
124 }
|
|
125 }
|
|
126 }
|