comparison UnitTests/Linq/Model/Person.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
3 using BLToolkit.Data.Sql.SqlProvider;
4 using BLToolkit.Mapping;
5 using BLToolkit.DataAccess;
6
7 namespace Data.Linq.Model
8 {
9 public class Person
10 {
11 public Person()
12 {
13 }
14
15 public Person(int id)
16 {
17 ID = id;
18 }
19
20 public Person(int id, string firstName)
21 {
22 ID = id;
23 FirstName = firstName;
24 }
25
26 [Identity, PrimaryKey]
27 //[SequenceName("PostgreSQL", "Seq")]
28 [SequenceName("Firebird", "PersonID")]
29 [MapField("PersonID")] public int ID;
30 public string FirstName { get; set; }
31 public string LastName;
32 [Nullable] public string MiddleName;
33 public Gender Gender;
34
35 [MapIgnore] public string Name { get { return FirstName + " " + LastName; }}
36
37 [Association(ThisKey = "ID", OtherKey = "PersonID", CanBeNull = true)]
38 public Patient Patient;
39
40 public override bool Equals(object obj)
41 {
42 return Equals(obj as Person);
43 }
44
45 public bool Equals(Person other)
46 {
47 if (ReferenceEquals(null, other)) return false;
48 if (ReferenceEquals(this, other)) return true;
49 return
50 other.ID == ID &&
51 Equals(other.LastName, LastName) &&
52 Equals(other.MiddleName, MiddleName) &&
53 other.Gender == Gender &&
54 Equals(other.FirstName, FirstName);
55 }
56
57 public override int GetHashCode()
58 {
59 unchecked
60 {
61 var result = ID;
62 result = (result * 397) ^ (LastName != null ? LastName.GetHashCode() : 0);
63 result = (result * 397) ^ (MiddleName != null ? MiddleName.GetHashCode() : 0);
64 result = (result * 397) ^ Gender.GetHashCode();
65 result = (result * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0);
66 return result;
67 }
68 }
69 }
70 }