Click here to Skip to main content
15,892,537 members
Articles / Web Development / ASP.NET

Filtering LINQ Queries Using Business Rules Engine

19 Nov 2012CPOL7 min read 35.4K   779   22  
This article discusses the use of one such new feature, namely, rule-based filtering of LINQ queries using Web Rule, the XML-based super-fast rules engine, implementable as an ASP.NET or MVC component.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

using System;
using CodeEffects.Rule.Attributes;
using CodeEffects.Rule.Common;

namespace CodeEffects.Rule.Demo.Filter.Asp.Common.Entities
{
	// See the following article for details on this interface and why do we need to declare it:
	// http://rule.codeeffects.com/Doc/Preserving-Attributes-In-Auto-Generated-Classes

	public interface IOrder
	{
		[ExcludeFromEvaluation]
		int OrderID { get; set; }

		[Field(DisplayName = "Product Description", ValueInputType = ValueInputType.User)]
		string ProductDescription { get; set; }

		[Field(DataSourceName = "ProductTypes", DisplayName = "Product Type")]
		int ProductTypeID { get; set; }

		[ExcludeFromEvaluation]
		string ProductTypeName { get; set; }

		[Field(DisplayName = "Product SKU Number", ValueInputType = ValueInputType.User)]
		string ProductSKU { get; set; }

		[Field(DataSourceName = "Colors", DisplayName = "Product Color")]
		int ColorID { get; set; }

		[ExcludeFromEvaluation]
		string ProductColorName { get; set; }

		[Field(DataSourceName = "Sizes", DisplayName = "Product Size")]
		int SizeID { get; set; }

		[ExcludeFromEvaluation]
		string ProductSizeName { get; set; }

		[Field(Min = 0, Max = 1000000, DisplayName = "Sub Total")]
		decimal Sub { get; set; }

		[Field(Min = 0, Max = 1000000, DisplayName = "Shipping Cost")]
		decimal Freight { get; set; }

		[Field(Min = 0, Max = 1000000, DisplayName = "Sale Tax")]
		decimal? Tax { get; set; }

		[Field(Min = 0, Max = 1000000)]
		decimal? Total { get; set; }

		[Field(DisplayName = "First Name", ValueInputType = ValueInputType.User)]
		string CustomerFirstName { get; set; }

		[Field(DisplayName = "Last Name", ValueInputType = ValueInputType.User)]
		string CustomerLastName { get; set; }

		[Field(DisplayName = "Email", ValueInputType = ValueInputType.User)]
		string CustomerEmail { get; set; }

		[Field(DisplayName = "Customer Company", ValueInputType = ValueInputType.User)]
		string CustomerCompany { get; set; }

		[Field(DisplayName = "Cell Phone", ValueInputType = ValueInputType.User)]
		string CustomerCellPone { get; set; }

		[Field(DateTimeFormat = "MMMM dd, yyyy", DisplayName = "Paid Date")]
		DateTime? DatePaid { get; set; }

		[Field(DateTimeFormat = "MMMM dd, yyyy", DisplayName = "Order Date")]
		DateTime DatePlaced { get; set; }

		[Field(DateTimeFormat = "MMMM dd, yyyy", DisplayName = "Date Shipped")]
		DateTime? DateShipped { get; set; }

		[Field(DisplayName = "Brand Description", ValueInputType = ValueInputType.User)]
		string ManufacturerName { get; set; }

		[Field(DisplayName = "Brand Description", ValueInputType = ValueInputType.User)]
		string ManufacturerDescription { get; set; }

		[Field(Min = 0, Max = 1000000, DisplayName = "Product Cost")]
		decimal ProductCost { get; set; }

		[Field(DateTimeFormat = "MMMM dd, yyyy", DisplayName = "Product Manufacture Date")]
		DateTime ProductionDate { get; set; }

		[Field(Min = 0, Max = 1000, DisplayName = "Product Weight in Kilos")]
		decimal? ProductWeight { get; set; }
	}
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions