Frage

it drives me crazy. I'm working at a Silverlight 5 Business Application and using WCF Ria Services (Domain Data Source). In a simple ChildControl I load the defined (see code below) domain data source "ddsTerminKonfiguration". The query method returns a generic IQueryable<TerminKonfiguration> list. If this list has no items (...DataView.Count == 0) I want to add a new object of "TerminKonfiguration". When I try to execute ddsTerminKonfiguration.DataView.Add(new TerminKonfiguration()); I run into an error "'Add' isn't supported by this ICollectionView" (I only know the german error message ... so I hope everybody can understand my translation :-D). Comparable code snippets in this project (coded by other developers) are working properly ... and I don't know, how to solve this problem.

Does anyone have an idea or solution for my problem?

My domain data source ...

<riaControls:DomainDataSource Name="ddsTerminKonfiguration"
                              Width="0"
                              Height="0"
                              AutoLoad="False"
                              d:DesignData="{d:DesignInstance my1:TerminKonfiguration, CreateList=true}"
                              LoadedData="ddsTerminKonfiguration_LoadedData"
                              SubmittedChanges="ddsTerminKonfiguration_SubmittedChanges"
                              QueryName="GetTerminKonfigurationQuery">
    <riaControls:DomainDataSource.DomainContext>
        <my:RRPDomainContext />
    </riaControls:DomainDataSource.DomainContext>
    <riaControls:DomainDataSource.QueryParameters>
        <riaControls:Parameter ParameterName="param01" />
        <riaControls:Parameter ParameterName="param02" />
        <riaControls:Parameter ParameterName="param03" />
        <riaControls:Parameter ParameterName="param04" />
    </riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>

The namespace "my" references to "Project".Web.Services and "my1" to "Project".Web.Models.

The query method ...

    public IQueryable<TerminKonfiguration> GetTerminKonfiguration(string param01, string param02, int param03, int param04) {
        return this.ObjectContext.TerminKonfiguration.Where(d => (d.MandantenNr == param01) && (d.WorkflowNr == param02) && (d.WfAufgabeId == param03) && (d.WfAufgabeIdGlobal == param04));
    }

The snippet, where I try to add the new object to the DataView ...

if (this.ddsTerminKonfiguration.DataView.Count == 0) {
    TerminKonfiguration tmpConfig = new TerminKonfiguration();
    /*
        define the new object
    */

    this.ddsTerminKonfiguration.DataView.Add(tmpConfig); // problematic line
}

this.ddsTerminKonfiguration.SubmitChanges();
War es hilfreich?

Lösung

DataView is a DataView this is the cause. DataView is the view of data.

With a datasource you can filter order etc then you see the effects on DataView.

 this.ddsTerminKonfiguration.DataView.Add is not a valid operation.

http://msdn.microsoft.com/en-us/library/ee707363(v=vs.91).aspx

Basic usage is

<Grid x:Name="LayoutRoot" Background="White">
<riaControls:DomainDataSource x:Name="source" QueryName="GetProductsByColor" AutoLoad="true">
    <riaControls:DomainDataSource.DomainContext>
        <domain:ProductDomainContext />
    </riaControls:DomainDataSource.DomainContext>
    <riaControls:DomainDataSource.QueryParameters>
        <riaData:Parameter ParameterName="color" Value="Black" />
    </riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>

 <data:DataGrid ItemsSource="{Binding Data, ElementName=source}" />

  </Grid>

As you notice it DataGrid bound to Data not DataView.

{Binding Data, ElementName=source}"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top