Ejemplo n.º 1
0
        public void saveObjectToDatabase <T>(T obj) where T : IIdentifiableObject
        {
            String key     = typeof(T).Name + "-" + obj.ID;
            String value   = converter.objectAsString(obj, typeof(T));
            var    azureKV = new AzureTableKeyValue(key, value);

            table.Execute(TableOperation.InsertOrReplace(azureKV));
        }
Ejemplo n.º 2
0
        public T getObjectFromDatabase <T>(String uniqId) where T : IIdentifiableObject
        {
            String key          = typeof(T).Name + "-" + uniqId;
            String partitionKey = AzureTableKeyValue.derivePartitionKeyFor(key);
            TableQuery <AzureTableKeyValue> query = new TableQuery <AzureTableKeyValue>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, key)
                    )
                );
            var results = table.ExecuteQuery <AzureTableKeyValue>(query);

            foreach (AzureTableKeyValue azureKv in results)
            {
                String value = azureKv.Value;
                return((T)converter.stringAsObject(value, typeof(T)));
            }
            return(default(T));
        }