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

Custom fields in partial class with its own expression

3 Answers 107 Views
Development (API, general questions)
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:49 PM
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
}
}

3 Answers, 1 is accepted

Sort by
0
Eugeniy
Top achievements
Rank 2
answered on 10 Nov 2011, 02:03 PM
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.

 

0
PetarP
Telerik team
answered on 14 Nov 2011, 06:16 PM
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!

0
Eugeniy
Top achievements
Rank 2
answered on 08 Feb 2012, 10:56 PM
deleted
Tags
Development (API, general questions)
Asked by
Eugeniy
Top achievements
Rank 2
Answers by
Eugeniy
Top achievements
Rank 2
PetarP
Telerik team
Share this question
or