0
|
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 } |