Exemplo n.º 1
0
        public static void Sync <T>(ISession session, CollectionDiffWithValue <T, T> diff)
        {
            ParamIs.NotNull(() => session);
            ParamIs.NotNull(() => diff);

            foreach (var n in diff.Removed)
            {
                session.Delete(n);
            }

            foreach (var n in diff.Added)
            {
                session.Save(n);
            }

            foreach (var n in diff.Edited)
            {
                session.Update(n);
            }
        }
Exemplo n.º 2
0
        public static void Sync <T>(this IDatabaseContext <T> ctx, CollectionDiffWithValue <T, T> diff)
        {
            ParamIs.NotNull(() => ctx);
            ParamIs.NotNull(() => diff);

            foreach (var n in diff.Removed)
            {
                ctx.Delete(n);
            }

            foreach (var n in diff.Added)
            {
                ctx.Save(n);
            }

            foreach (var n in diff.Edited)
            {
                ctx.Update(n);
            }
        }