// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
namespace Microsoft.Web.Http.Data
{
///
/// Represents a change operation to be performed on an entity.
///
[DataContract]
[DebuggerDisplay("Operation = {Operation}, Type = {Entity.GetType().Name}")]
public sealed class ChangeSetEntry
{
///
/// Gets or sets the client ID for the entity
///
[DataMember]
public int Id { get; set; }
///
/// Gets or sets the to be performed on the entity.
///
[DataMember]
public ChangeOperation Operation { get; set; }
///
/// Gets or sets the being operated on
///
[DataMember]
public object Entity { get; set; }
///
/// Gets or sets the original state of the entity being operated on
///
[DataMember(EmitDefaultValue = false)]
public object OriginalEntity { get; set; }
///
/// Gets or sets the state of the entity in the data store
///
[DataMember(EmitDefaultValue = false)]
public object StoreEntity { get; set; }
///
/// Gets or sets the custom methods invoked on the entity, as a set
/// of method name / parameter set pairs.
///
[DataMember(EmitDefaultValue = false)]
public IDictionary EntityActions { get; set; }
///
/// Gets or sets the validation errors encountered during the processing of the operation.
///
[DataMember(EmitDefaultValue = false)]
public IEnumerable ValidationErrors { get; set; }
///
/// Gets or sets the collection of members in conflict. The property
/// contains the current store value for each member in conflict.
///
[DataMember(EmitDefaultValue = false)]
public IEnumerable ConflictMembers { get; set; }
///
/// Gets or sets whether the conflict is a delete conflict, meaning the
/// entity no longer exists in the store.
///
[DataMember(EmitDefaultValue = false)]
public bool IsDeleteConflict { get; set; }
///
/// Gets or sets the collection of IDs of the associated entities for
/// each association of the Entity
///
[DataMember(EmitDefaultValue = false)]
public IDictionary Associations { get; set; }
///
/// Gets or sets the collection of IDs for each association of the
///
[DataMember(EmitDefaultValue = false)]
public IDictionary OriginalAssociations { get; set; }
///
/// Gets a value indicating whether the contains conflicts.
///
public bool HasConflict
{
get { return (IsDeleteConflict || (ConflictMembers != null && ConflictMembers.Any())); }
}
public bool HasError
{
get { return HasConflict || (ValidationErrors != null && ValidationErrors.Any()); }
}
internal UpdateActionDescriptor ActionDescriptor { get; set; }
}
}