0

ria-service で使用される 3 つのクラスがあります。

最初はレスポンスクラスです:

[DataContract]
public class ValidationResponseContainer
{
    [DataMember]
    public string EntityId { get; set; }

    [DataMember]
    public bool IsWarning { get; set; }

    [DataMember]
    public string ConstraintName { get; set; }

    [DataMember]
    public IEnumerable<string> Fields { get; set; }
}

2 番目は KeyValuePair<> のようなものです。

[DataContract]
public class FieldValueContainer
{
    [DataMember]
    public Guid ConstraintId { get; set; }

    [DataMember]
    public string FieldName { get; set; }

    [DataMember]
    public string Value { get; set; }
}

3 番目はリクエストです。

[DataContract]
[KnownType(typeof(FieldValueContainer))]
public class ValidationRequestContainer
{
    [DataMember]
    public string EntityId { get; set; }

    [DataMember]
    public string TableName { get; set; }

    [DataMember]
    public IEnumerable<FieldValueContainer> FieldValues { get; set; }

    public ValidationRequestContainer()
    {
        FieldValues = new List<FieldValueContainer>();
    }
}

プロジェクトをデプロイした後、EventLog に次のエラーが表示されました。

Exception System.Runtime.Serialization.InvalidDataContractException Type 'System.Linq.Enumerable+WhereSelectEnumerableIterator`2[_2020vision.Infrastructure.FieldValueContainer,System.String]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.
   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String message, Type type)

データ契約クラスの何が問題になっていますか?

4

0 に答える 0