diff UnitTests/Linq/L2SAttributes.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/L2SAttributes.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,56 @@
+using System;
+using System.Data.Linq.Mapping;
+
+using NUnit.Framework;
+
+using BLToolkit.Common;
+using BLToolkit.Data.Linq;
+
+namespace Data.Linq
+{
+	[Table(Name = "Person")]
+	public class L2SPersons
+	{
+		private int _personID;
+
+		[Column(
+			Storage       = "_personID",
+			Name          = "PersonID",
+			DbType        = "integer(32,0)",
+			IsPrimaryKey  = true,
+			IsDbGenerated = true,
+			AutoSync      = AutoSync.Never,
+			CanBeNull     = false)]
+		public int PersonID
+		{
+			get { return _personID;  }
+			set { _personID = value; }
+		}
+		[Column] public string FirstName { get; set; }
+		[Column] public string LastName;
+		[Column] public string MiddleName;
+		[Column] public string Gender;
+	}
+
+	[TestFixture]
+	public class L2SAttributes : TestBase
+	{
+		[Test]
+		public void IsDbGeneratedTest([IncludeDataContexts("Sql2008", "Sql2012")] string context)
+		{
+			using (var db = new TestDbManager(context))
+			{
+				db.BeginTransaction();
+
+				var id = db.InsertWithIdentity(new L2SPersons
+				{
+					FirstName = "Test",
+					LastName  = "Test",
+					Gender    = "M"
+				});
+
+				db.GetTable<L2SPersons>().Delete(p => p.PersonID == ConvertTo<int>.From(id));
+			}
+		}
+	}
+}