Silverlight 4 Domainservice problem
Why the methods of DomainService which have parameters of complex types (all types except int, bool, float,...) are not recognizable in Model? in build and even in intelisense! :(
Update
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<开发者_如何学CKhorasanMISEntities>
{
// 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;
}
//***********************************************************
}
}
The method in the stars-comment can not be used in a model but if I change its parameter to int, it will become usable.
Check out the documentation of DomainServices. Insert, update and delete operation are handled by the EntitySet and the SubmitChanges method on the client side.
When you expose a domain service, an EntitySet object is generated in the domain context with properties that indicate which operations (insert, update, or delete) are permitted from the client. You execute data modifications by modifying the entity collection and then calling the SubmitChanges method.
精彩评论