1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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 MoreComplexSample
18 using Castle
.ActiveRecord
;
19 using NHibernate
.Expression
;
21 [ActiveRecord("LineItem")]
22 public class LineItem
: ActiveRecordBase
<LineItem
>
26 private Product product
;
27 private int? quantity
;
33 public LineItem(Order order
, Product product
)
36 this.product
= product
;
39 [PrimaryKey(PrimaryKeyType
.Guid
)]
46 [BelongsTo("OrderId", NotNull
= true, UniqueKey
= "ConstraintName")]
50 set { order = value; }
53 [BelongsTo("ProductId", NotNull
= true, UniqueKey
= "ConstraintName")]
54 public Product Product
56 get { return product; }
57 set { product = value; }
63 get { return quantity; }
64 set { quantity = value; }
67 public static LineItem
Find(Order order
, Product product
)
69 return FindOne(Expression
.Eq("Order", order
), Expression
.Eq("Product", product
));