2011-02-14 65 views
0

爲什麼具有複雜類型參數(除int,bool,float之外的所有類型)的DomainService方法在Model中不可識別? 建立,甚至在intelisense! :(Silverlight 4 Domainservice問題

更新

CODE

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,就會變得可用。

+0

能否請您進一步解釋一下?我猜Silverlight 8是一個typeo?你有一些代碼來顯示問題嗎? – 2011-02-14 08:44:51

回答

0

查看DomainServices的文檔插入,更新和刪除操作由客戶端的EntitySet和SubmitChanges方法處理。

當您公開域服務時,會在域上下文中生成一個EntitySet對象,其中的屬性指示允許來自客戶端的操作(插入,更新或刪除)。您可以通過修改實體集合然後調用SubmitChanges方法來執行數據修改。