diff HowTo/Mapping/FluentMapping.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/HowTo/Mapping/FluentMapping.cs	Thu Mar 27 21:46:09 2014 +0400
@@ -0,0 +1,38 @@
+using System;
+
+using BLToolkit.Mapping;
+using BLToolkit.Mapping.Fluent;
+using BLToolkit.Mapping.MemberMappers;
+
+namespace HowTo.Mapping
+{
+    public class Category
+    {
+        public int    CategoryID;
+        public string CategoryName;
+        public string Description;
+        public Binary Picture;
+        public TimeSpan RefreshTime;
+        public AdditionalInfo AdditionalInfo;
+        public List<Product> Products;
+    }
+    
+    public class CategoryMap : FluentMap<Category>
+    {
+        public CategoryMap()
+        {
+            TableName("Categories");
+            PrimaryKey(_ => _.CategoryID).Identity();
+            Nullable(_ => _.Description);
+            Nullable(_ => _.Picture);
+            MapField(_ => _.RefreshTime).MemberMapper(typeof(TimeSpanBigIntMapper)).DbType(System.Data.DbType.Int64);
+            MapField(_ => _.AdditionalInfo).MapIgnore(false).MemberMapper(typeof(BinarySerialisationMapper)).DbType(System.Data.DbType.Byte);
+            Association(_ => _.Products,_ => _.CategoryID).ToMany((Product _) => _.CategoryID);
+        }
+    }
+    
+    public static void Main()
+    {
+        FluentConfig.Configure(Map.DefaultSchema).MapingFromAssemblyOf<Category>();
+    }
+}
\ No newline at end of file