Scalar Function Column

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

    Posted 09 Nov 2011 Link to this 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
       }
    }

    Is any way to do the thing like that in current version?
  2. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 09 Nov 2011 Link to this post

    Or more greater

    public class Telerik.OpenAccess.ExpressionAttribute<Product> : Attribute
    {
       public virtual Expression GetExpression()
        {
              return PropertyExpression...;
        }
    }

    so we could create custom attributes, derived from Telerik.ExpressionAttribute and provide any expression we want...
  3. DevCraft banner
  4. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 14 Nov 2011 Link to this post

    Hi Eugeniy,

    Indeed this is the right solution to your problem. 

    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

    Hello, i have tried this.
    Why not to have it in the telerik open access, it's simple to use:

    partial class DetailTable
    {
    [jExpressionProperty("OwnerLogin", null)]
    [DataMember()]
    public string OwnerName
    {
    get
    {
    if (OwnerLogin != null) return OwnerLogin.Trim();
    return null;
    }
    }
    public static Expression<Func<Virtual, DateTime?>> LastUsageDateExpression = v => v.Rents.Any()? v.Rents.Max(r=>r.CreationDate):(DateTime?) null;
    [jExpressionProperty(null, null)]
    [DataMember]
    public DateTime? LastUsageDate
    {
    get
    {
    return (DateTime?)jExpressionPropertyHelper.GetValue(this,LastUsageDateExpression);
    }
    }
    }


  6. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 10 Feb 2012 Link to this post

    Hello Eugeniy,

     Unfortunately such scenarios are still not supported by OpenAccess. Can you please share with us what you are trying to achieve exactly and perhaps we can offer you a suitable workaround.

    All the best,
    Petar
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  7. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 25 Jul 2012 Link to this post

    I'm using it to sort,filter and group RadDomainDataSource+RadGridView by column that is calculated via lambda expressions and is not presented at DataBase.
    In my earlier example I was using LastUsageDate as it would be presented at database, but it is not.
    Here is the code for that:

    http://jslcore.codeplex.com/SourceControl/changeset/view/14180#180670
  8. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 27 Jul 2012 Link to this post

    Hello Eugeniy,

    I am afraid that no significant development time has been put into that feature and the things are still as they were before. This is still not supported scenario and I am afraid I cannot give you a time frame when we will support that.

    Kind regards,
    Petar
    the Telerik team
    OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
  9. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 27 Jul 2012 Link to this post

    That is ok!
    I just mean that such kind of feauture would be great, this is the new unique way to create calculatable columns.
    It is usefull but most developers are not thinking this way (creating calculatable columns within linq expressions).
    This post is just my idea about telerik could be the first company in it. The first company which shows developers this way.
    I have already implemented this feauture and used it within several projects.
    If it is interesting for you - i could write a post about What does it do, How to implement it and How to use it.

    If no - this post will be usefull for developers trying to work this way within Open Access - it is possible, i'm using columns declared via Labmda Expression with Open Access and LinqToSql as well.
  10. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 01 Aug 2012 Link to this post

    Hi Eugeniy,

    Thank you for the effort and the feedback.

    We will of course appreciate it if you share your approach with the OpenAccess community. You can submit the solution with the appropriate description as a Code Library sample. In such cases we are offering Telerik Points (awarded based on our review of the sample) as a small reward for your dedication to the community.

    Do not hesitate to get back to us if you need any further details about the sample or you have any other questions.

    All the best,
    Ivailo
    the Telerik team
    OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
  11. Eugeniy
    Eugeniy avatar
    60 posts
    Member since:
    Feb 2011

    Posted 08 Aug 2012 Link to this post

    Hello again.
    I have uploaded the example, but it does not appear at code library section.
  12. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 08 Aug 2012 Link to this post

    Hi Eugeniy,

    Thank you for uploading the Code Library sample. It is already visible for us and we will run the normal process of reviewing it before making it available to the entire community.

    We will let you know if we have any questions or if there are any changes we would like to make.

    Kind regards,
    Ivailo
    the Telerik team
    OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
Back to Top
DevCraft banner