Wednesday, 22 June 2011

Filter NuGet Package updated

Thirteen Dynamic Data Custom Filters has been updated to Dynamic Data 15 Custom Filters and the PackageId is now “DynamicData.CustomFilters”, makes more sense than “DynamicData.ThirteenFilters” especially it now had 15 filters instead of 13.

I have added

  • GreaterThanOrEqual
  • LessThanOrEqual
Sample Metadata
[MetadataTypeAttribute(typeof(Product.ProductMetadata))]
public partial class Product
{
    internal sealed class ProductMetadata
    {
        [FilterUIHint("MultiForeignKey")]
        public Category Category { get; set; }

        public Nullable<int> CategoryID { get; set; }

        public bool Discontinued { get; set; }

        public EntityCollection<Order_Detail> Order_Details { get; set; }

        public int ProductID { get; set; }

        public string ProductName { get; set; }

        public string QuantityPerUnit { get; set; }

        public Nullable<short> ReorderLevel { get; set; }

        public Supplier Supplier { get; set; }

        public Nullable<int> SupplierID { get; set; }

        [FilterUIHint("GreaterThanOrEqual")]
        public Nullable<decimal> UnitPrice { get; set; }

        [FilterUIHint("LessThanOrEqual")]
        public Nullable<short> UnitsInStock { get; set; }

        public Nullable<short> UnitsOnOrder { get; set; }
    }
}

Much fun I expect there will be more soon.

2 comments:

roberto said...

hello steve

I always follow the developments and I'm implementing a tui console on dinamic websites

I find myself with a problem to be resolved with respect to the use of filters


through NuGet I installed on my project in vs 2010, the package "filter"
I have a project in vb, so I translated correctly all the components and the class in vb LinqExpressionHelper

I now find myself in an error in all ascx vb filter
c#
private Expression BuildQueryBody(ParameterExpression parameterExpression)
{
Expression propertyExpression = LinqExpressionHelper.GetValue(LinqExpressionHelper.CreatePropertyExpression(parameterExpression, Column.Name));
TypeConverter converter = TypeDescriptor.GetConverter(Column.ColumnType);
BinaryExpression minimumComparison = BuildCompareExpression(propertyExpression, converter.ConvertFromString(DateFrom), Expression.GreaterThanOrEqual);
return minimumComparison;
}

private BinaryExpression BuildCompareExpression(Expression propertyExpression, object value, Func comparisonFunction)
{
ConstantExpression valueExpression = Expression.Constant(value);
BinaryExpression comparison = comparisonFunction(propertyExpression, valueExpression);
return comparison;
}

In vb
Private Function BuildQueryBody(parameterExpression As ParameterExpression) As Expression
Dim propertyExpression As Expression = LinqExpressionHelper.GetValue(LinqExpressionHelper.CreatePropertyExpression(parameterExpression, Column.Name))
Dim converter As TypeConverter = TypeDescriptor.GetConverter(Column.ColumnType)
Dim minimumComparison As BinaryExpression = BuildCompareExpression(propertyExpression, converter.ConvertFromString(DateFrom), Expression.GreaterThanOrEqual)
Return minimumComparison
End Function

Private Function BuildCompareExpression(propertyExpression As Expression, value As Object, comparisonFunction As Func(Of Expression, Expression, BinaryExpression)) As BinaryExpression
Dim valueExpression As ConstantExpression = Expression.Constant(value)
Dim comparison As BinaryExpression = comparisonFunction(propertyExpression, valueExpression)
Return comparison
End Function

in expression ... I find the error
Risoluzione dell'overload non riuscita perché nessun 'GreaterThanOrEqual' accessibile accetta questo numero di argomenti.
Overload resolution failed because no 'GreaterThanOrEqual' accepts this number of argument available.

Steve said...

Sorry Roberto try posting the error in the VB forum relating to Linq I'm sure someone there will be able to help. My VB is really rusty sorry.

Steve