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
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...
http://www.telerik.com/community/forums/reply-thread.aspx?messageId=0&threadId=481484
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!
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);
}
}
}
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
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
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.
Petar
the Telerik team
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.
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.
Ivailo
the Telerik team
I have uploaded the example, but it does not appear at code library section.
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.
Ivailo
the Telerik team