This is a migrated thread and some comments may be shown as answers.

Scalar Function Column

11 Answers 104 Views
Feature Requests
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eugeniy
Top achievements
Rank 2
Eugeniy asked on 09 Nov 2011, 07:43 PM
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?

11 Answers, 1 is accepted

Sort by
0
Eugeniy
Top achievements
Rank 2
answered on 09 Nov 2011, 08:39 PM
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...
0
Eugeniy
Top achievements
Rank 2
answered on 10 Nov 2011, 02:04 PM
0
PetarP
Telerik team
answered on 14 Nov 2011, 06:18 PM
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!

0
Eugeniy
Top achievements
Rank 2
answered on 08 Feb 2012, 10:57 PM
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);
}
}
}


0
PetarP
Telerik team
answered on 10 Feb 2012, 03:59 PM
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 >>
0
Eugeniy
Top achievements
Rank 2
answered on 25 Jul 2012, 07:49 AM
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
0
PetarP
Telerik team
answered on 27 Jul 2012, 01:27 PM
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.
0
Eugeniy
Top achievements
Rank 2
answered on 27 Jul 2012, 01:56 PM
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.
0
Ivailo
Telerik team
answered on 01 Aug 2012, 09:39 AM
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.
0
Eugeniy
Top achievements
Rank 2
answered on 08 Aug 2012, 09:38 AM
Hello again.
I have uploaded the example, but it does not appear at code library section.
0
Ivailo
Telerik team
answered on 08 Aug 2012, 11:07 AM
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.
Tags
Feature Requests
Asked by
Eugeniy
Top achievements
Rank 2
Answers by
Eugeniy
Top achievements
Rank 2
PetarP
Telerik team
Ivailo
Telerik team
Share this question
or