Ejemplo n.º 1
0
        public static int SaveChanges <T> (this DbContext context, IDbContextSerializer <T> serializer, T writable)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var writer = serializer.CreateWriter(writable);

            using (writer as IDisposable)
                return(context.SaveChanges(writer));
        }
Ejemplo n.º 2
0
        public static void SerializeGraphChanges <T> (this DbContext context, IDbContextSerializer <T> serializer, T writable, params object [] items)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var writer = serializer.CreateWriter(writable);

            using (writer as IDisposable)
                context.SerializeGraphChanges(writer, items);
        }
Ejemplo n.º 3
0
        public static void Serialize <T> (this DbContext context, IDbContextSerializer <T> serializer, T writable)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var writer = serializer.CreateWriter(writable);

            using (writer as IDisposable)
                context.Serialize(writer);
        }
Ejemplo n.º 4
0
        public static async Task <int> SaveChangesAsync <T> (this DbContext context, IDbContextSerializer <T> serializer, T writable, CancellationToken cancellationToken = default)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var writer = serializer.CreateWriter(writable);

            using (writer as IDisposable)
                return(await context.SaveChangesAsync(writer, cancellationToken)
                       .ConfigureAwait(false));
        }