comparison HowTo/Mapping/FluentMapping.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.Mapping;
4 using BLToolkit.Mapping.Fluent;
5 using BLToolkit.Mapping.MemberMappers;
6
7 namespace HowTo.Mapping
8 {
9 public class Category
10 {
11 public int CategoryID;
12 public string CategoryName;
13 public string Description;
14 public Binary Picture;
15 public TimeSpan RefreshTime;
16 public AdditionalInfo AdditionalInfo;
17 public List<Product> Products;
18 }
19
20 public class CategoryMap : FluentMap<Category>
21 {
22 public CategoryMap()
23 {
24 TableName("Categories");
25 PrimaryKey(_ => _.CategoryID).Identity();
26 Nullable(_ => _.Description);
27 Nullable(_ => _.Picture);
28 MapField(_ => _.RefreshTime).MemberMapper(typeof(TimeSpanBigIntMapper)).DbType(System.Data.DbType.Int64);
29 MapField(_ => _.AdditionalInfo).MapIgnore(false).MemberMapper(typeof(BinarySerialisationMapper)).DbType(System.Data.DbType.Byte);
30 Association(_ => _.Products,_ => _.CategoryID).ToMany((Product _) => _.CategoryID);
31 }
32 }
33
34 public static void Main()
35 {
36 FluentConfig.Configure(Map.DefaultSchema).MapingFromAssemblyOf<Category>();
37 }
38 }