Hi
Can you tell me how to make Insert/Delete row work for the radgridview which has the source as a set of Inheritance entity?
I think my problem right now is that i still can't figure out a way to wrap the Ienumerable into an IList, IEditablecollection , or EntityCollectionView because i check on your EntityCollectionView at http://www.telerik.com/community/forums/silverlight/gridview/mvvm-and-gridview-saving-change-ria-services.aspx
and don't see any construction which will accept an Ienumerable as an argument (only EntityCollection or EntitySet). Your help will be appreciated.
This is my situation:
I have a DocumentLine table and DocumentLineBudget table in the database. By using Entity Framework, I make the DocumentLineBudget entity will inherit from the DocumentLine entity.
Because of this inheritance, when i try to create a Domain service to retrieve DocumentLineBudget list , the normal pop up window(if choosing Domain Service Class template) will grey out the DocumentLineBudget and won't let me choose it.
So I create the operation in my DocumentLineService.cs file to retrieve the list of DocumentLineBudget through the function GetDocumentLineBudgets()
The problem now is that if i use DomainDataSource control which i normally use, then i won't see the GetDocumentLineBudgetsQuery() option on the DataSource toolbar for the DocumentLineContext in order to let me drag and drop the Gridview into the designer.
so my only choice now is not using the DomainDataSource. So i use the code behind like this
Right now, i can load the data of the DocumentLineBudget including DocumentLine properties through inheritance properly. However, I can't insert new data back into the database. The Grid won't let me do that
I realize that in my code i use DocumentLine instead of DocumentLineBudget
So the grid only let me delete but not insert because the property of the DocumentLineBudget won't update.
but if i use, then it won't work too because the EntitySetCollectionView only accept EntitySet argument not an Ienumerable
I try to use PageCollectionView to wrap around "lop.Entities" which will return an Ienumerable DocumentLineBudget but also doesn't work
Can you help me how to make the function Insert/ Delete work properly in my case?
what kind of collections does the Radgridview support built-in Insert/Delete? . For my case right now is that the lop.Entities will return an Ienumerable DocumentLineBudgets . If i feed it to the itemssource of the gridview, then i won't get the feature Insert/Delete.
thank you
Can you tell me how to make Insert/Delete row work for the radgridview which has the source as a set of Inheritance entity?
I think my problem right now is that i still can't figure out a way to wrap the Ienumerable into an IList, IEditablecollection , or EntityCollectionView because i check on your EntityCollectionView at http://www.telerik.com/community/forums/silverlight/gridview/mvvm-and-gridview-saving-change-ria-services.aspx
and don't see any construction which will accept an Ienumerable as an argument (only EntityCollection or EntitySet). Your help will be appreciated.
This is my situation:
I have a DocumentLine table and DocumentLineBudget table in the database. By using Entity Framework, I make the DocumentLineBudget entity will inherit from the DocumentLine entity.
Because of this inheritance, when i try to create a Domain service to retrieve DocumentLineBudget list , the normal pop up window(if choosing Domain Service Class template) will grey out the DocumentLineBudget and won't let me choose it.
So I create the operation in my DocumentLineService.cs file to retrieve the list of DocumentLineBudget through the function GetDocumentLineBudgets()
namespace
Test_SilverFinancial.Web.Services
{
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.ComponentModel.DataAnnotations;
using
System.Data;
using
System.Linq;
using
System.ServiceModel.DomainServices.EntityFramework;
using
System.ServiceModel.DomainServices.Hosting;
using
System.ServiceModel.DomainServices.Server;
using
Test_SilverFinancial.Web.Models;
// Implements application logic using the SilverFinancialsEntities context.
// TODO: Add your application logic to these methods or in additional methods.
// TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
// Also consider adding roles to restrict access as appropriate.
// [RequiresAuthentication]
[EnableClientAccess()]
public
class
DocumentLineService : LinqToEntitiesDomainService<SilverFinancialsEntities>
{
/////////////////////////Extra Operation Services/////////////////////////////
/// <summary>
/// GetDocumentLines by DocumentId
/// </summary>
/// <param name="documentLine"></param>
public
IQueryable<DocumentLine> GetDocumentLinesById(
int
documentId)
{
return
this
.ObjectContext.DocumentLines.Where(d => d.DocumentId == documentId);
}
public
IQueryable<DocumentLineBudget> GetDocumentLineBudgets()
{
return
this
.ObjectContext.DocumentLines.OfType<DocumentLineBudget>().AsQueryable();
}
////////////////////////////////////////////////////////////////////////////////
// TODO:
// Consider constraining the results of your query method. If you need additional input you can
// add parameters to this method or create additional query methods with different names.
// To support paging you will need to add ordering to the 'DocumentLines' query.
public
IQueryable<DocumentLine> GetDocumentLines()
{
return
this
.ObjectContext.DocumentLines;
}
public
void
InsertDocumentLine(DocumentLine documentLine)
{
if
((documentLine.EntityState != EntityState.Detached))
{
this
.ObjectContext.ObjectStateManager.ChangeObjectState(documentLine, EntityState.Added);
}
else
{
this
.ObjectContext.DocumentLines.AddObject(documentLine);
}
}
public
void
UpdateDocumentLine(DocumentLine currentDocumentLine)
{
this
.ObjectContext.DocumentLines.AttachAsModified(currentDocumentLine,
this
.ChangeSet.GetOriginal(currentDocumentLine));
}
public
void
DeleteDocumentLine(DocumentLine documentLine)
{
if
((documentLine.EntityState == EntityState.Detached))
{
this
.ObjectContext.DocumentLines.Attach(documentLine);
}
this
.ObjectContext.DocumentLines.DeleteObject(documentLine);
}
}
}
The problem now is that if i use DomainDataSource control which i normally use, then i won't see the GetDocumentLineBudgetsQuery() option on the DataSource toolbar for the DocumentLineContext in order to let me drag and drop the Gridview into the designer.
so my only choice now is not using the DomainDataSource. So i use the code behind like this
namespace
Test_SilverFinancial.Windows
{
public
partial
class
DocumentLineBudgetGridView : RadWindow
{
private
DocumentLineContext dl_ctx;
public
DocumentLineBudgetGridView()
{
InitializeComponent();
dl_ctx =
new
DocumentLineContext();
EntityQuery<DocumentLineBudget> query = dl_ctx.GetDocumentLineBudgetsQuery();
LoadOperation<DocumentLineBudget> lop = dl_ctx.Load(query);
documentLineBudgetGridView.ItemsSource =
new
EntitySetCollectionView<DocumentLine>(dl_ctx.DocumentLines);
}
private
void
documentLineBudgetGridView_RowEditEnded(
object
sender, GridViewRowEditEndedEventArgs e)
{
this
.dl_ctx.SubmitChanges();
}
private
void
documentLineBudgetGridView_Deleted(
object
sender, GridViewDeletedEventArgs e)
{
this
.dl_ctx.SubmitChanges();
}
}
}
Right now, i can load the data of the DocumentLineBudget including DocumentLine properties through inheritance properly. However, I can't insert new data back into the database. The Grid won't let me do that
I realize that in my code i use DocumentLine instead of DocumentLineBudget
documentLineBudgetGridView.ItemsSource =
new
EntitySetCollectionView<DocumentLine>(dl_ctx.DocumentLines);
So the grid only let me delete but not insert because the property of the DocumentLineBudget won't update.
but if i use, then it won't work too because the EntitySetCollectionView only accept EntitySet argument not an Ienumerable
documentLineBudgetGridView.ItemsSource =
new
EntitySetCollectionView<DocumentLineBudget>(lop.Entities);
I try to use PageCollectionView to wrap around "lop.Entities" which will return an Ienumerable DocumentLineBudget but also doesn't work
Can you help me how to make the function Insert/ Delete work properly in my case?
what kind of collections does the Radgridview support built-in Insert/Delete? . For my case right now is that the lop.Entities will return an Ienumerable DocumentLineBudgets . If i feed it to the itemssource of the gridview, then i won't get the feature Insert/Delete.
thank you