|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeProject.Data.Entity;
namespace InvoiceSample
{
partial class SampleInvoiceContext
{
partial void OnContextCreated()
{
new OptimisticConcurrencyManager(this);
}
}
[AssociationEndBehaviorAttribute("Lines", Owned=true)]
[OptimisticConcurrency("LastChanged", typeof(LocalDateTimeConcurrencyResolver))]
partial class Invoice {
/// <summary>
/// TotalPrice, an additional derived property.
/// </summary>
public Decimal TotalPrice
{
get {
Decimal totalPrice = 0m;
foreach (InvoiceLine line in this.Lines)
{
if (line.LinePrice.HasValue)
totalPrice += line.LinePrice.Value;
}
return totalPrice;
}
}
public override string ToString()
{
return String.Format("Invoice {0} ({1})", this.Identifier, this.InvoiceDate);
}
}
[OptimisticConcurrency("LastChanged", typeof(LocalDateTimeConcurrencyResolver))]
partial class InvoiceLine {
/// <summary>
/// LinePrice, an additional derived property.
/// </summary>
public Decimal? LinePrice
{
get { return (this.Quantity.HasValue && this.UnitPrice.HasValue) ? (decimal?)((decimal)this.Quantity.Value * this.UnitPrice.Value) : null; }
}
public override string ToString()
{
return String.Format("InvoiceLine {0} ({1}:{2}, {3}x${4})", this.ID, this.Product.ID, this.Product.Label, this.Quantity, this.UnitPrice);
}
}
[OptimisticConcurrency("LastChanged", typeof(LocalDateTimeConcurrencyResolver))]
partial class Customer {
public override string ToString()
{
return String.Format("Customer {0} ({1})", this.Identifier, this.Name);
}
}
[OptimisticConcurrency("LastChanged", typeof(LocalDateTimeConcurrencyResolver))]
partial class Product {
public override string ToString()
{
return String.Format("Product {0} ({1})", this.ID, this.Label);
}
}
[OptimisticConcurrency("LastChanged", typeof(LocalDateTimeConcurrencyResolver))]
partial class Supplier {
public override string ToString()
{
return String.Format("Supplier {0} ({1})", this.ID, this.Name);
}
}
[OptimisticConcurrency("LastChanged", typeof(LocalDateTimeConcurrencyResolver))]
partial class CatalogFolder
{
public override string ToString()
{
return String.Format("CatalogFolder {0} ({1})", this.ID, this.Name);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.