Dapper.SimpleSave.Impl.ReverseUpdateHelper.IsReverseUpdateWithChildReferencingParent C# (CSharp) Method

IsReverseUpdateWithChildReferencingParent() public static method

public static IsReverseUpdateWithChildReferencingParent ( UpdateOperation update ) : bool
update UpdateOperation
return bool
        public static bool IsReverseUpdateWithChildReferencingParent(UpdateOperation update)
        {
            var ownerPropMeta = update.OwnerPropertyMetadata;
            if (null == ownerPropMeta)
            {
                return false;
            }

            if (!ownerPropMeta.HasAttribute<OneToManyAttribute>()
                && !ownerPropMeta.HasAttribute<OneToOneAttribute>())
            {
                return false;
            }

            var valueMeta = update.ValueMetadata;
            if (valueMeta.IsReferenceData
                && valueMeta.HasUpdateableForeignKeys)
            {
                return true;
            }

            return ownerPropMeta.HasAttribute<ReferenceDataAttribute>()
                && ownerPropMeta.GetAttribute<ReferenceDataAttribute>().HasUpdateableForeignKeys;
        }
    }

Usage Example

 private static void AppendUpdateCommand(Script script, UpdateCommand command, ref int paramIndex)
 {
     if (ReverseUpdateHelper.IsReverseUpdateWithChildReferencingParent(command.Operations.First()))
     {
         AppendReverseUpdateCommandForChildTableReferencingParent(script, command, ref paramIndex);
     }
     else
     {
         AppendStandardUpdateCommand(script, command, ref paramIndex);
     }
 }
All Usage Examples Of Dapper.SimpleSave.Impl.ReverseUpdateHelper::IsReverseUpdateWithChildReferencingParent