【发布时间】:2014-03-05 09:26:55
【问题描述】:
以下类是使用实体框架模型从模板自动生成的。
namespace Entities
{
using System;
using System.Collections.Generic;
public partial class Country
{
public Country()
{
this.Regions = new HashSet<Region>();
}
public long CountryId { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public bool Preferred { get; set; }
public System.DateTime LastChanged { get; set; }
public virtual ICollection<Region> Regions { get; set; }
}
}
我有一个只返回 POX (Xml) 和 Json 的 Wcf Web 服务。我想返回我自己的序列化对象,例如;
public class MyResponseObject
{
public int RequestId {get;set;}
public List<Country> CountryList {get;set;}
//other properties
}
但我不想返回 Regions ICollection。
然后可以使用类似
的方式返回该对象Newtonsoft.Json.JsonConvert.SerializeObject()
我最好以这种方式返回我自己的序列化 POCO 对象吗?
【问题讨论】:
标签: c# wcf entity-framework