Пример #1
0
        public static bool TryGet(string name, DataStoreRetrieveOption option, out DataStoreItem item)
        {
            if (name == null)
            {
                throw new ArgumentNullException();
            }

            using (var rCommand = r_Connection.CreateCommand())
            {
                rCommand.CommandText = option == DataStoreRetrieveOption.IncludeContent
                    ? "SELECT content, timestamp FROM datastore.item WHERE name = @name;"
                    : "SELECT NULL, timestamp FROM datastore.item WHERE name = @name;";
                rCommand.Parameters.AddWithValue("@name", name);

                using (var rReader = rCommand.ExecuteReader())
                {
                    if (!rReader.Read())
                    {
                        item = default(DataStoreItem);
                        return(false);
                    }

                    item = new DataStoreItem(name, rReader[0] as byte[], rReader.GetInt64Optional(1));
                    return(true);
                }
            }
        }
Пример #2
0
 public static bool TryGet(string name, out DataStoreItem item) => TryGet(name, DataStoreRetrieveOption.IncludeContent, out item);