Проблема с Silverlight 4 Domainservice - PullRequest
0 голосов
/ 14 февраля 2011

Почему методы DomainService, которые имеют параметры сложных типов (все типы, кроме int, bool, float, ...), не распознаются в Model? в строю и даже в интеллекте! (

Обновление

КОД

namespace KhorasanMIS.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 KhorasanMIS.Web.Entities;



  // Implements application logic using the KhorasanMISEntities 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 DSCountry : LinqToEntitiesDomainService<KhorasanMISEntities>
  {

    // 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 'Countries' query.
    public IQueryable<Country> GetCountries()
    {
      return this.ObjectContext.Countries;
    }

    public IEnumerable<Country> GetCountryByCode(string pCode)
    {
      return this.ObjectContext.Countries.Where(a => a.ISOCode.Equals(pCode));
    }


    public bool IsValidEdit(string pCode)
    {
      List<string> message = new List<string>();
      IEnumerable<Country> list = GetCountryByCode(pCode);
      if (list.Count() > 0)
      {
        return false;
      }      
      return true;
    }

    //***********************************************************
    public bool Update(Country currentItem)
    {
      this.ObjectContext.Countries.AttachAsModified(currentItem, this.ChangeSet.GetOriginal(currentItem));
      return true;
    }
    //***********************************************************


  }
}

Метод в комментариях к звездам нельзя использовать в модели, но если я изменю его параметр на int, он станет пригодным для использования.

1 Ответ

0 голосов
/ 14 февраля 2011

Ознакомьтесь с документацией DomainServices .Операции вставки, обновления и удаления обрабатываются EntitySet и методом SubmitChanges на стороне клиента.

Когда вы предоставляете доменную службу, объект EntitySet генерируется в контексте домена со свойствами, которые указывают, какиеоперации (вставка, обновление или удаление) разрешены клиентом.Вы выполняете модификации данных, изменяя коллекцию сущностей и затем вызывая метод SubmitChanges.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...