文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>笔记-使用WCF RIA Service Class Library

笔记-使用WCF RIA Service Class Library

时间:2011-02-25  来源:阿胜

3.新增一个WCF RIA Service Class Library。在xxx.web项目新增一个文件夹Models,并新增一个类Customer。 

public class Customer
{
    [Key]
    public int CustomerId { get; set; }
    public string LastName { get; set; }
    public string FirstName { get; set; }
    public string EmailAddress { get; set; }
 
 
    public IList<Customer> GetRetrieve()
    {
        List<Customer> custList = new List<Customer>
                {new Customer()
                      { CustomerId = 1,
                        FirstName="Bilbo",
                        LastName = "Baggins",
                        EmailAddress = "[email protected]"},
                new Customer()
                      { CustomerId = 2,
                        FirstName="Frodo",
                        LastName = "Baggins",
                        EmailAddress = "[email protected]"},
                new Customer()
                      { CustomerId = 3,
                        FirstName="Samwise",
                        LastName = "Gamgee",
                        EmailAddress = "[email protected]"},
                new Customer()
                      { CustomerId = 4,
                        FirstName="Rosie",
                        LastName = "Cotton",
                        EmailAddress = "[email protected]"}};
        return custList;
    }
}

然后在SLRIA项目引用SLRIAService项目,SLRIA.WEB项目引用SLRIAService.web项目。

接着绑定数据到DataGrid。这里不细说。运行程序。会出现下面的错误提示。 

这时需要在Web.config添加下面的配置节点。

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
 
      <httpModules>
        <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </httpModules>
      
    </system.web>
 
</configuration>

参考资料:http://msdn.microsoft.com/en-us/library/ee707336%28v=vs.91%29.aspx

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载