public IDbSetConfigurationQueryOptions <TContext, TProperty1> ConfigureSet <TProperty1>(
     Expression <Func <TContext, DbSet <TProperty1> > > dbSetExpression, string fieldName,
     SetOption setOption = SetOption.IncludeAsFieldAndChild,
     Expression <Func <TProperty1, bool> >?defaultFilter = null)
     where TProperty1 : class
 {
     return(_options.ConfigureSet(dbSetExpression, fieldName, setOption, defaultFilter));
 }
Example #2
0
        /// <summary>
        /// `JSON.SET`
        ///
        /// Sets the JSON value at path in key
        ///
        /// For new Redis keys the path must be the root.
        ///
        /// For existing keys, when the entire path exists, the value that it contains is replaced with the json value.
        ///
        /// https://oss.redislabs.com/rejson/commands/#jsonset
        /// </summary>
        /// <param name="db"></param>
        /// <param name="key">Key where JSON object is to be stored.</param>
        /// <param name="json">The JSON object which you want to persist.</param>
        /// <param name="path">The path which you want to persist the JSON object. For new objects this must be root.</param>
        /// <param name="setOption">By default the object will be overwritten, but you can specify that the object be set only if it doesn't already exist or to set only IF it exists.</param>
        /// <param name="commandFlags">Optional command flags.</param>
        /// <returns>An `OperationResult` indicating success or failure.</returns>
        public static OperationResult JsonSet(this IDatabase db, RedisKey key, string json, string path = ".",
                                              SetOption setOption = SetOption.Default, CommandFlags commandFlags = CommandFlags.None)
        {
            var result = db.Execute(JsonCommands.SET,
                                    CombineArguments(key, path, json, GetSetOptionString(setOption)),
                                    flags: commandFlags)
                         .ToString();

            return(new OperationResult(result == "OK", result));
        }
Example #3
0
 public void SetFlags(EnvironmentFlag flags, SetOption option = SetOption.Add)
 {
     if (!closed && _envPtr != IntPtr.Zero)
     {
         Env.SetFlags(_envPtr, flags, option == SetOption.Add);
     }
     else
     {
         throw new InvalidOperationException("MDBX environment is not open.");
     }
 }
        /// <summary>
        /// `JSON.SET`
        ///
        /// Sets the JSON value at path in key
        ///
        /// For new Redis keys the path must be the root.
        ///
        /// For existing keys, when the entire path exists, the value that it contains is replaced with the json value.
        ///
        /// https://oss.redislabs.com/rejson/commands/#jsonset
        /// </summary>
        /// <param name="db"></param>
        /// <param name="key">Key where JSON object is to be stored.</param>
        /// <param name="json">The JSON object which you want to persist.</param>
        /// <param name="path">The path which you want to persist the JSON object. For new objects this must be root.</param>
        /// <param name="setOption">By default the object will be overwritten, but you can specify that the object be set only if it doesn't already exist or to set only IF it exists.</param>
        /// <param name="commandFlags">Optional command flags.</param>
        /// <returns>An `OperationResult` indicating success or failure.</returns>
        public static async Task <OperationResult> JsonSetAsync(this IDatabaseAsync db, RedisKey key, string json,
                                                                string path = ".", SetOption setOption = SetOption.Default, CommandFlags commandFlags = CommandFlags.None)
        {
            var result =
                (await db.ExecuteAsync(
                     JsonCommands.SET,
                     CombineArguments(key, path, json, GetSetOptionString(setOption)),
                     flags: commandFlags)
                 .ConfigureAwait(false)).ToString();

            return(new OperationResult(result == "OK", result));
        }
        private static string GetSetOptionString(SetOption setOption)
        {
            switch (setOption)
            {
            case SetOption.Default:
                return(string.Empty);

            case SetOption.SetIfNotExists:
                return("NX");

            case SetOption.SetOnlyIfExists:
                return("XX");

            default:
                return(string.Empty);
            }
        }
Example #6
0
        public IDbSetConfigurationQueryOptions <TContext, TProperty> ConfigureSet <TProperty>(
            Expression <Func <TContext, DbSet <TProperty> > > dbSetExpression,
            string fieldName    = null,
            SetOption setOption = SetOption.IncludeAsFieldAndChild,
            Expression <Func <TProperty, bool> > defaultFilter = null)
            where TProperty : class
        {
            var dbSetConfiguration = new DbSetConfiguration
            {
                Type             = typeof(TProperty),
                SetOption        = setOption,
                FieldName        = fieldName,
                FilterExpression = defaultFilter
            };

            ((List <IDbSetConfiguration>)DbSetConfigurations).Add(dbSetConfiguration);

            return(new DbSetConfigurationQueryOptions <TContext, TProperty>(this, dbSetConfiguration));
        }
Example #7
0
        public void SetOption(string optionName, string optionValue)
        {
            var option = new SetOption(optionName, optionValue);

            QueueCommand(option);
        }
Example #8
0
 /// <summary>
 /// The clusterfuck
 /// </summary>
 private async Task DocumentOpsInternal(object documentDataToSet, SetOption setOption, (string fieldPath, object[] objs) arrayOperation = default)
Example #9
0
 /// <summary>
 /// `JSON.SET`
 ///
 /// Sets the JSON value at path in key
 ///
 /// For new Redis keys the path must be the root.
 ///
 /// For existing keys, when the entire path exists, the value that it contains is replaced with the json value.
 ///
 /// https://oss.redislabs.com/rejson/commands/#jsonset
 /// </summary>
 /// <param name="db"></param>
 /// <param name="key">Key where JSON object is to be stored.</param>
 /// <param name="json">The JSON object which you want to persist.</param>
 /// <param name="path">The path which you want to persist the JSON object. For new objects this must be root.</param>
 /// <param name="setOption">By default the object will be overwritten, but you can specify that the object be set only if it doesn't already exist or to set only IF it exists.</param>
 /// <returns></returns>
 public static RedisResult JsonSet(this IDatabase db, RedisKey key, string json, string path = ".", SetOption setOption = SetOption.Default) =>
 db.Execute(JsonCommands.SET, CombineArguments(key, path, json, GetSetOptionString(setOption)));
 /// <summary>
 /// `JSON.SET`
 ///
 /// Sets the JSON value at path in key
 ///
 /// For new Redis keys the path must be the root.
 ///
 /// For existing keys, when the entire path exists, the value that it contains is replaced with the json value.
 ///
 /// https://oss.redislabs.com/rejson/commands/#jsonset
 /// </summary>
 /// <param name="db"></param>
 /// <param name="key">Key where JSON object is to be stored.</param>
 /// <param name="obj">The object to serialize and send.</param>
 /// <param name="path">The path which you want to persist the JSON object. For new objects this must be root.</param>
 /// <param name="setOption">By default the object will be overwritten, but you can specify that the object be set only if it doesn't already exist or to set only IF it exists.</param>
 /// <param name="commandFlags"></param>
 /// <typeparam name="TObjectType">Type of the object being serialized.</typeparam>
 /// <returns>An `OperationResult` indicating success or failure.</returns>
 public static Task <OperationResult> JsonSetAsync <TObjectType>(this IDatabaseAsync db, RedisKey key,
                                                                 TObjectType obj,
                                                                 string path = ".", SetOption setOption = SetOption.Default,
                                                                 CommandFlags commandFlags = CommandFlags.None) =>
 db.JsonSetAsync(key, SerializerProxy.Serialize(obj), path, setOption, commandFlags: commandFlags);
 /// <summary>
 /// `JSON.SET`
 ///
 /// Sets the JSON value at path in key
 ///
 /// For new Redis keys the path must be the root.
 ///
 /// For existing keys, when the entire path exists, the value that it contains is replaced with the json value.
 ///
 /// https://oss.redislabs.com/rejson/commands/#jsonset
 /// </summary>
 /// <param name="db"></param>
 /// <param name="key">Key where JSON object is to be stored.</param>
 /// <param name="obj">The object to serialize and send.</param>
 /// <param name="path">The path which you want to persist the JSON object. For new objects this must be root.</param>
 /// <param name="setOption">By default the object will be overwritten, but you can specify that the object be set only if it doesn't already exist or to set only IF it exists.</param>
 /// <param name="index">By default the JSON object will not be assigned to an index, specify this value and it will.</param>
 /// <typeparam name="TObjectType">Type of the object being serialized.</typeparam>
 /// <returns>An `OperationResult` indicating success or failure.</returns>
 public static Task <OperationResult> JsonSetAsync <TObjectType>(this IDatabase db, RedisKey key, TObjectType obj, string path = ".", SetOption setOption = SetOption.Default, string index = "") =>
 db.JsonSetAsync(key, SerializerProxy.Serialize(obj), path, setOption, index);
        /// <summary>
        /// `JSON.SET`
        ///
        /// Sets the JSON value at path in key
        ///
        /// For new Redis keys the path must be the root.
        ///
        /// For existing keys, when the entire path exists, the value that it contains is replaced with the json value.
        ///
        /// https://oss.redislabs.com/rejson/commands/#jsonset
        /// </summary>
        /// <param name="db"></param>
        /// <param name="key">Key where JSON object is to be stored.</param>
        /// <param name="json">The JSON object which you want to persist.</param>
        /// <param name="path">The path which you want to persist the JSON object. For new objects this must be root.</param>
        /// <param name="setOption">By default the object will be overwritten, but you can specify that the object be set only if it doesn't already exist or to set only IF it exists.</param>
        /// <param name="index">By default the JSON object will not be assigned to an index, specify this value and it will.</param>
        /// <returns>An `OperationResult` indicating success or failure.</returns>
        public static async Task <OperationResult> JsonSetAsync(this IDatabase db, RedisKey key, string json, string path = ".", SetOption setOption = SetOption.Default, string index = "")
        {
            var result = (await db.ExecuteAsync(JsonCommands.SET, CombineArguments(key, path, json, GetSetOptionString(setOption), ResolveIndexSpecification(index)))).ToString();

            return(new OperationResult(result == "OK", result));
        }
		public void SetOption(SetOption option, string val)
		{
			dbe.SetOption((int)option, val);
		}
		public void SetOption(SetOption option, int val)
		{
			dbe.SetOption((int)option, val);
		}