如何使ICollection可序列化.net 4.0 [英] how to make ICollection serializable .net 4.0

查看:196
本文介绍了如何使ICollection可序列化.net 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Web服务来获取员工数据。我正在使用EF 4.0并创建了一个可在webservice中访问的可序列化employeewrapper类。

我需要帮助序列化外键关系类以访问相关数据。



如何使名称和客户端可序列化?



目前我的代码是:



 [Serializable] 
public class EmployeeWrapper
{
public string FirstName {获得; set ; }
public string MiddleName { get ; set ; }
public short DesignationId { get ; set ; }

public virtual 指定名称{获得; set ; }
public virtual ICollection< Client>客户{{span class =code-keyword>获取
; set ; }

public EmployeeWrapper()
{
this .Client = new HashSet< Client>();
}
}

解决方案

请看下面的链接。

http://stackoverflow.com/questions/639303/how-to-serialize-collections-网内 [ ^ ]

I am creating a web service to fetch the employee data. I am using EF 4.0 and have created a serializable employeewrapper class accessible in webservice.
I need help in serializing the foreign key relationship classes to access the related data as well.

How to make Designation and Client serializable?

Currently my code is:

[Serializable]
    public class EmployeeWrapper
    {
        public string FirstName { get; set; }
        public string MiddleName { get; set; }
        public short DesignationId { get; set; }

        public virtual Designation Designation { get; set; }
        public virtual ICollection<Client> Client { get; set; }

        public EmployeeWrapper()
        {
    		this.Client = new HashSet<Client>();
        }
    }

解决方案

Please have a look at below link.
http://stackoverflow.com/questions/639303/how-to-serialize-collections-in-net[^]


这篇关于如何使ICollection可序列化.net 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆