Applied patch from Jan Limpens 'ReflectionBasedDictionaryAdapter needs to check if...
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / LazyModel / ProductLazy.cs
blob473b15e078cfb2bef521f91f9481fd76caa60825
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.ActiveRecord.Tests.Model.LazyModel
17 using System;
19 using Iesi.Collections;
22 [ActiveRecord]
23 public class ProductLazy : ActiveRecordValidationBase
25 private int id;
26 private ISet categories = new HashedSet();
28 public ProductLazy()
32 [PrimaryKey]
33 public int Id
35 get { return id; }
36 set { id = value; }
39 [HasMany( typeof(CategoryLazy), Lazy=true, Cascade=ManyRelationCascadeEnum.All )]
40 public ISet Categories
42 get { return categories; }
43 set { categories = value; }
46 public static void DeleteAll()
48 ActiveRecordBase.DeleteAll( typeof(ProductLazy) );
51 public static ProductLazy[] FindAll()
53 return (ProductLazy[]) ActiveRecordBase.FindAll( typeof(ProductLazy) );
56 public static ProductLazy Find(int id)
58 return (ProductLazy) ActiveRecordBase.FindByPrimaryKey( typeof(ProductLazy), id );
62 [ActiveRecord]
63 public class CategoryLazy : ActiveRecordValidationBase
65 private int id;
66 private String name;
67 private ProductLazy product;
69 public CategoryLazy()
73 public CategoryLazy(String name)
75 this.name = name;
78 [PrimaryKey]
79 public int Id
81 get { return id; }
82 set { id = value; }
85 [Property]
86 public string Name
88 get { return name; }
89 set { name = value; }
92 [BelongsTo("product_id")]
93 public ProductLazy Product
95 get { return product; }
96 set { product = value; }