Beispiel #1
0
        protected static long GetRemoteId <T> (IDataStoreContext ctx, Guid id)
            where T : CommonData
        {
            var remoteId = ctx.GetRemoteId <T> (id);

            if (remoteId == null)
            {
                throw new RelationRemoteIdMissingException(typeof(T), id);
            }
            return(remoteId.Value);
        }
Beispiel #2
0
        protected static long?GetRemoteId <T> (IDataStoreContext ctx, Guid?id)
            where T : CommonData, new()
        {
            if (id == null)
            {
                return(null);
            }
            var remoteId = ctx.GetRemoteId <T> (id.Value);

            if (remoteId == null)
            {
                // Check that the relation is actually non-existent, not just remoteId unset
                var hasRelation = ctx.Connection.Table <T> ().Count(r => r.Id == id) > 0;
                if (hasRelation)
                {
                    throw new RelationRemoteIdMissingException(typeof(T), id.Value);
                }
            }
            return(remoteId);
        }