Пример #1
0
        private Task <bool> Exist(EventDb db, EventEntity <TPrimaryKey> entity)
        {
            switch (entity.ActorId)
            {
            case long id:
            {
                var paramId = id;
                var table   = db.Table <long>().TableName(this.tableName);
                return(table.Where(o => o.ActorId == paramId && o.Name == entity.Name && o.FlowId == entity.FlowId).AnyAsync());
            };

            case string id:
            {
                var paramId = id;
                var table   = db.Table <string>().TableName(this.tableName);
                return(table.Where(o => o.ActorId == paramId && o.Name == entity.Name && o.FlowId == entity.FlowId).AnyAsync());
            };

            case Guid id:
            {
                var paramId = id;
                var table   = db.Table <Guid>().TableName(this.tableName);
                return(table.Where(o => o.ActorId == paramId && o.Name == entity.Name && o.FlowId == entity.FlowId).AnyAsync());
            };

            default: throw new ArgumentOutOfRangeException(typeof(TPrimaryKey).FullName);
            }
        }