Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Samples / ActiveRecord / MoreComplexSample / LineItem.cs
blob0ce2edb80cad9890395583b3414911ae8c6f387f
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 MoreComplexSample
17 using System;
18 using Castle.ActiveRecord;
19 using NHibernate.Expression;
21 [ActiveRecord("LineItem")]
22 public class LineItem : ActiveRecordBase<LineItem>
24 private Guid id;
25 private Order order;
26 private Product product;
27 private int? quantity;
29 public LineItem()
33 public LineItem(Order order, Product product)
35 this.order = order;
36 this.product = product;
39 [PrimaryKey(PrimaryKeyType.Guid)]
40 public Guid Id
42 get { return id; }
43 set { id = value; }
46 [BelongsTo("OrderId", NotNull = true, UniqueKey = "ConstraintName")]
47 public Order Order
49 get { return order; }
50 set { order = value; }
53 [BelongsTo("ProductId", NotNull = true, UniqueKey = "ConstraintName")]
54 public Product Product
56 get { return product; }
57 set { product = value; }
60 [Property]
61 public int? Quantity
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));