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

Anonymous types scenarios OA ORM...

2 Answers 51 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ubuntu
Top achievements
Rank 1
Ubuntu asked on 25 Apr 2011, 06:44 PM
Dear all,

I want to know if it is possible to have the following scenarios ...

First:
-
Create a user-defined type and use it as projection to return result from DomainService and Bind it to SL DataGrid as follows:
public partial class summaryview
{
    [Key]
    public int period { get; set; }
    [Key]
    public short month_number { get; set; }
    [Key]
    public long daily_number { get; set; }
    [Key]
    public int subsidiary_id { get; set; }
    public string comp_dailynumber
    {
        get { return string.Format("{0} / {1}", this.month_number, this.daily_number); }
    }
    public int discriptor { get; set; }
    public long? manual_number { get; set; }
    public DateTime daily_date { get; set; }
    public string notes_1 { get; set; }
    public decimal? total_credit { get; set; }
    public decimal? total_debit { get; set; }
The projection method on DomainService:
public IQueryable<dailysummeryview> Getdailysummery_View(int posted)
{
#region Custom Class
  
var dailys = (from Summary in DataContext.dailysummeries
join Period in DataContext.Periods on Summary.period_id equals Period.period_id
where
Summary.post_status == posted
&& Summary.daily_date >= Period.date_from
&& Summary.daily_date <= Period.date_to
&& Period.closed != 1
select new dailysummaryview
      {
      period = Summary.period_id,
      month_number = Summary.month_number,
      daily_number = Summary.daily_number,
      subsidiary_id = Summary.subsidiary_id,
      discriptor = Summary.discriptor,
      manual_number = Summary.manual_number,
      daily_date = Summary.daily_date,
      notes_1 = Summary.notes_1,
      total_credit = details.Sum(k => k.credit),
      total_debit = details.Sum(k => k.debit),
      });
      return dailys;
#endregion
}
The client SL application is using QDSCV to receive the return from Getdailysummery_View and bind it to DataGrid

Second:
- if the previous scenario is applicable, can this be extended to allow user interaction a little bit as follows:

- Define a custom type (joins 4 tables) to display a collection of columns to the end-user
- A user can add/delete rows from/into the grid and submit those changes back to the OA ORM.

Fast reply is much needed !!.
Regards

2 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 28 Apr 2011, 04:53 PM
Hi Ubuntu,

As I replied to your other thread, using a custom type which is a projection over several persistent types as a domain service endpoint should work as long as the linq query underneath is supported.
However, using this type for insert/delete operations will not work as this is not really a persistent type which OpenAccess knows how to handle in such situations. A possible solution would be to define the projection as a view in the database and map this view to a persistent class. The insert and delete operations will still not work this way automatically, but you will be able to generate insert/update/delete stored procedures for the persistent type, which will be used instead of the dynamically generated SQL. You can then alter the stored procedures so that they update properly each table exposed by this view.

Greetings,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ubuntu
Top achievements
Rank 1
answered on 22 May 2011, 05:04 PM
Hello Alexander,

I followed your proposed solution and I am little bit late to define the current issue, anyway I just relaized that I posted a new thread here: http://www.telerik.com/community/forums/orm/getting-started/anonymous-type-on-view-not-refreshed.aspx

I just wonder, how to refresh the view using the QDSCV Load function as in my scenario it isn't ..

Appreciate your help
Tags
Getting Started
Asked by
Ubuntu
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Ubuntu
Top achievements
Rank 1
Share this question
or