Custom fields in partial class with its own expression

4 posts, 0 answers
  1. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 09 Nov 2011 Link to this post

    I just have written a suggestion: http://www.telerik.com/community/forums/orm/feature-requests/scalar-function-column.aspx
    Is any way in current version to do this, can I somehow handle the query - i want to make the injection (based on field attribute) in to the select query
    Original post:
    writing partial classes is cool, because we can add custom property:

    public partial class Product
    {
    public
    string UserName
    {
    get
    {
    return User.Login.Trim();
    }
    }
    }

    There is a problem with such kind of fields: RIA cannot perform SQL operation (sorting, grouping and filtering) with it.
    It would be great, if we can write just a field:

    public partial class Product
    {

    [Telerik.OpenAccess.ExpressionField<Product>(product=>product.User.Login.Trim)]
    public string Name;
    }
    And in SilverLight RIA DataContext class it would be:

    public string UserName
    {
    get
    {
    return _userName; // wich was calculated on server before sending to client
    }
    }
  2. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 10 Nov 2011 Link to this post

    I've developed a solution:

    http://jslcore.codeplex.com/SourceControl/changeset/changes/8699

    We can mark custom properties with jExpressionPropertyAttribute attribute.
    And then, instead of calling Table:
    new jPropertyQueryable( someTable).Where().Order()....
    or just use extension method:
    jSLCore.Service.Workflow.Linq.LinqExtension.ExecutejProperties<T>(IQueryable<T> ...)

    The bad news is that there is impossble to create any Expression within the attribute.
    At my realization we can just provide Property and SubProperty names for target column.

     

  3. DevCraft banner
  4. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 14 Nov 2011 Link to this post

    Hello Eugeniy,

     We are happy that you have found a solution that worked for your case. And yes, your assumptions are correct. Indeed it is not possible to provide an Expression within the the attribute.

    All the best,
    Petar
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

  5. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 08 Feb 2012 Link to this post

    deleted
Back to Top