diff UnitTests/Linq/Model/Person.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/Linq/Model/Person.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,70 @@
+using System;
+
+using BLToolkit.Data.Sql.SqlProvider;
+using BLToolkit.Mapping;
+using BLToolkit.DataAccess;
+
+namespace Data.Linq.Model
+{
+	public class Person
+	{
+		public Person()
+		{
+		}
+
+		public Person(int id)
+		{
+			ID = id;
+		}
+
+		public Person(int id, string firstName)
+		{
+			ID        = id;
+			FirstName = firstName;
+		}
+
+		[Identity, PrimaryKey]
+		//[SequenceName("PostgreSQL", "Seq")]
+		[SequenceName("Firebird",   "PersonID")]
+		[MapField("PersonID")] public int    ID;
+		                       public string FirstName { get; set; }
+		                       public string LastName;
+		[Nullable]             public string MiddleName;
+		                       public Gender Gender;
+
+		[MapIgnore]            public string Name { get { return FirstName + " " + LastName; }}
+
+		[Association(ThisKey = "ID", OtherKey = "PersonID", CanBeNull = true)]
+		public Patient Patient;
+
+		public override bool Equals(object obj)
+		{
+			return Equals(obj as Person);
+		}
+
+		public bool Equals(Person other)
+		{
+			if (ReferenceEquals(null, other)) return false;
+			if (ReferenceEquals(this, other)) return true;
+			return
+				other.ID == ID &&
+				Equals(other.LastName,   LastName) &&
+				Equals(other.MiddleName, MiddleName) &&
+				other.Gender == Gender &&
+				Equals(other.FirstName,  FirstName);
+		}
+
+		public override int GetHashCode()
+		{
+			unchecked
+			{
+				var result = ID;
+				result = (result * 397) ^ (LastName   != null ? LastName.GetHashCode()   : 0);
+				result = (result * 397) ^ (MiddleName != null ? MiddleName.GetHashCode() : 0);
+				result = (result * 397) ^ Gender.GetHashCode();
+				result = (result * 397) ^ (FirstName  != null ? FirstName.GetHashCode()  : 0);
+				return result;
+			}
+		}
+	}
+}