0
LINQ-to-SQLを使用していますが、シリアライゼーションモードを単方向に設定しています。DataContractSerializerでシリアル化されていない接続エンティティ
私は、1対多の関係を持つCountry
とCity
の2つのエンティティクラスを持っています。
DataContractSerializer serializer =
new DataContractSerializer(typeof(IList<Country>), new[] {
typeof(EntitySet<City>) // I have also tried with typeof(City)
});
string xml;
using (Db db = new Db()) {
IList<Country> countries = db.Countries.ToList();
// ... some manipulation of the list here, add/remove etc ...
StringBuilder sb = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(sb))
serializer.WriteObject(writer, countries);
xml = sb.ToString();
}
結果のXML文字列がCountry
エンティティが、その中にありませんCity
実体を持っています。
どうすれば解決できますか?