Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OData服务和Silverlight客户端使用不同于服务器端的对象,我可以这样做吗?_C#_Silverlight_Windows Phone 7_Odata - Fatal编程技术网

C# OData服务和Silverlight客户端使用不同于服务器端的对象,我可以这样做吗?

C# OData服务和Silverlight客户端使用不同于服务器端的对象,我可以这样做吗?,c#,silverlight,windows-phone-7,odata,C#,Silverlight,Windows Phone 7,Odata,我正在使用ODataV2库和DataServiceState类开发WP7应用程序(基于MSDN中的ODataWPNorthwindSample) 在本例中,我有MainViewModel.cs类,其中 > DataServiceCollection<Customer> customers; > > public DataServiceCollection<Customer> Customers > { >

我正在使用ODataV2库和DataServiceState类开发WP7应用程序(基于MSDN中的ODataWPNorthwindSample) 在本例中,我有MainViewModel.cs类,其中

> DataServiceCollection<Customer> customers;
> 
>   public DataServiceCollection<Customer> Customers 
>         {
>             get { return this.customers; }
> 
>             private set
>             {
>                 this.customers = value;
>                 
>                 this.customers.LoadCompleted +=
> this.OnCustomersLoaded;
>                 this.customers.CollectionChanged += (o, e) => {
> this.NotifyPropertyChanged("CustomersTitle"); };
> 
>                 this.NotifyPropertyChanged("Customers");
>                 this.NotifyPropertyChanged("CustomersTitle");
>             }
>         }
出于某种原因,我需要再添加一个属性“AddressLocal”,该属性将仅在客户端使用,并将其绑定到XAML。我根据“Address”属性计算的“AddressLocal”的值。所以,如果“地址”改变,“地址本地”也会改变

>  public string AddressLocal
>     {
>         get
>         {
>             return this._ AddressLocal;
>         }
>         set
>         {
>             this.On AddressLocal Changing(value);
>             this._AddressLocal = value;
>             this.OnAddressLocal Changed();
>             this.OnPropertyChanged("AddressLocal ");
>         }
>     }
>     
>     private string _AddressLocal;
>     partial void OnAddressLocal Changing(string value);
>     partial void OnAddressLocal Changed();
但是这个属性在服务器上的数据库中不存在,我不需要它们,但是当我调用

> App.ViewModel.Context.BeginSaveChanges(OnSaveCompleted, null);
> 
> void OnSaveCompleted(IAsyncResult asyncResult)
>         {
>             Deployment.Current.Dispatcher.BeginInvoke(() =>
>             {
>                 try
>                 {
>                     App.ViewModel.Context.EndSaveChanges(asyncResult);
>                     this.StatusMessage.Text = "Successfully saved
> changes";
>                 }
这是给我一个例外,因为 数据服务收集客户;与上下文中的客户对象不同。 我知道这可能是因为我在应用程序架构中犯了错误。
我的第一个想法是:创建一个OBSELECT“CustomerLocal”并从客户继承,但这不起作用。你知道吗

如果将附加属性设置为内部,则SaveChanges应忽略它。

如果将附加属性设置为内部,则SaveChanges应忽略它。

是的,您的权利,我可以这样做,但我之前提到过,我需要将此属性绑定到Silverlight,在XAML文件中:
您还有其他想法吗?是的,您的权利,我可以这样做,但我之前提到过,我需要将此属性绑定到Silverlight,在XAML文件中:
您还有其他想法吗?
> App.ViewModel.Context.BeginSaveChanges(OnSaveCompleted, null);
> 
> void OnSaveCompleted(IAsyncResult asyncResult)
>         {
>             Deployment.Current.Dispatcher.BeginInvoke(() =>
>             {
>                 try
>                 {
>                     App.ViewModel.Context.EndSaveChanges(asyncResult);
>                     this.StatusMessage.Text = "Successfully saved
> changes";
>                 }