Example #1
0
        public object Assign(ITenant tenant, TDoc document, out bool assigned)
        {
            var original = _getter != null?_getter(document) : default(TId);

            var id = _generator.Assign(tenant, original, out assigned);

            if (assigned)
            {
                if (_setter == null)
                {
                    throw new InvalidOperationException($"The identity of {typeof(TDoc)} cannot be assigned");
                }

                _setter(document, id);
            }

            return(id);
        }