本文整理汇总了C#中Models.GetRepository方法的典型用法代码示例。如果您正苦于以下问题:C# Models.GetRepository方法的具体用法?C# Models.GetRepository怎么用?C# Models.GetRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Models
的用法示例。
在下文中一共展示了Models.GetRepository方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public void Delete(Models.MediaContent content)
{
string sql = string.Format("DELETE FROM {0} WHERE [email protected]", content.GetRepository().GetMediaContentTableName());
SqlCeCommand command = new SqlCeCommand();
command.CommandText = sql;
command.Parameters.Add(new SqlCeParameter("UUID", content.UUID));
SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
}
示例2: ClearCategories
public void ClearCategories(Models.TextContent content)
{
var bucket = content.GetRepository().GetClient();
var view = bucket.GetView(content.GetRepository().GetDefaultViewDesign(), "CategorisData_By_ContentUUID").Stale(StaleMode.False).Reduce(false);
var ret = view.Where(it => it.Info["value"].ToString().Equals(content.UUID)).Select(it => it.ItemId);
ret.ForEach((key, index) =>
{
bucket.Remove(key);
});
}
示例3: Update
public void Update(Models.MediaContent @new, Models.MediaContent old)
{
((IPersistable)@new).OnSaving();
string sql = string.Format("UPDATE {0} SET FolderName = @FolderName,FileName = @FileName,[email protected]) WHERE [email protected]"
, @new.GetRepository().GetMediaContentTableName());
SqlCeCommand command = new SqlCeCommand();
command.CommandText = sql;
command.Parameters.Add(new SqlCeParameter("UUID", @new.UUID));
command.Parameters.Add(new SqlCeParameter("FolderName", @new.FolderName));
command.Parameters.Add(new SqlCeParameter("FileName", @new.FileName));
command.Parameters.Add(new SqlCeParameter("VirtualPath", @new.VirtualPath));
SQLCeHelper.ExecuteNonQuery(@new.GetRepository().GetConnectionString(), command);
((IPersistable)@new).OnSaved();
}
示例4: Add
public void Add(Models.MediaContent content)
{
((IPersistable)content).OnSaving();
string sql = string.Format("INSERT INTO {0}(UUID,FolderName,FileName,VirtualPath,UserId) VALUES(@UUID,@FolderName,@FileName,@VirtualPath,@UserId)"
, content.GetRepository().GetMediaContentTableName());
SqlCeCommand command = new SqlCeCommand();
command.CommandText = sql;
command.Parameters.Add(new SqlCeParameter("UUID", content.UUID));
command.Parameters.Add(new SqlCeParameter("FolderName", content.FolderName));
command.Parameters.Add(new SqlCeParameter("FileName", content.FileName));
command.Parameters.Add(new SqlCeParameter("VirtualPath", content.VirtualPath));
command.Parameters.Add(new SqlCeParameter("UserId", content.UserId));
SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
((IPersistable)content).OnSaved();
}
示例5: Generate
public override string Generate(Models.ContentBase content)
{
string userKey = content.UserKey;
if (string.IsNullOrEmpty(userKey))
{
userKey = GetColumnValueForUserKey(content);
}
if (string.IsNullOrEmpty(userKey))
{
userKey = content.UUID;
}
else
{
string sperator = content.GetRepository().AsActual().UserKeyHyphens;
userKey = PinyinConverter.GetPinyin(userKey, sperator);
if (userKey.Length > 256)
{
userKey = userKey.Substring(0, 256);
}
var tmpUserKey = EscapeUserKey(content, userKey);
int tries = 0;
while (IfUserKeyExists(content, tmpUserKey))
{
tries++;
tmpUserKey = userKey + sperator + tries.ToString();
}
userKey = tmpUserKey;
}
return userKey;
}
示例6: ClearCategories
public void ClearCategories(Models.TextContent content)
{
//((IPersistable)content).OnSaving();
MongoCollection<BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
var query = new QueryDocument { { "ContentUUID", content.UUID } };
collection.Remove(query);
//((IPersistable)content).OnSaved();
}
示例7: Delete
public void Delete(Models.TextContent content)
{
var database = content.GetRepository().GetDatabase();
MongoCollection<BsonDocument> collection = database.GetCollection(content.GetSchema().GetSchemaCollectionName());
var query = new QueryDocument { { "UUID", content.UUID } };
collection.Remove(query);
TextContentFileHelper.DeleteFiles(content);
}
示例8: DeleteCategories
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
{
var bucket = content.GetRepository().GetClient();
categories.ForEach((it, index) =>
{
bucket.ExecuteRemove(it.GetDocumentKey(), PersistTo.One);
});
}
示例9: AddCategories
public void AddCategories(Models.TextContent content, params Models.Category[] categories)
{
//((IPersistable)content).OnSaving();
if (categories != null && categories.Length > 0)
{
MongoCollection<BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
collection.InsertBatch(categories.Select(it => it.ToBsonDocument()).ToArray());
}
//((IPersistable)content).OnSaved();
}
示例10: DeleteCategories
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
{
//((IPersistable)content).OnSaving();
if (categories != null && categories.Length > 0)
{
MongoCollection<BsonDocument> collection = content.GetRepository().GetCategoriesCollection();
var query = MongoDBQuery.Query.Or(categories.Select(it => new QueryComplete(it.ToBsonDocument())).ToArray());
collection.Remove(query);
}
//((IPersistable)content).OnSaved();
}
示例11: Add
public void Add(Models.TextContent content)
{
content.Remove("_id");
content.StoreFiles();
((IPersistable)content).OnSaving();
var database = content.GetRepository().GetDatabase();
MongoCollection<BsonDocument> collection = database.GetCollection(content.GetSchema().GetSchemaCollectionName());
collection.Insert(content.ToBsonDocument());
((IPersistable)content).OnSaved();
}
示例12: AddCategories
public void AddCategories(Models.TextContent content, params Models.Category[] categories)
{
if (categories != null && categories.Length > 0)
{
var bucket = content.GetRepository().GetClient();
categories.ForEach((it, index) =>
{
bucket.ExecuteStore(StoreMode.Set, it.GetDocumentKey(), it.ToJson(), PersistTo.One);
});
}
}
示例13: Update
public void Update(Models.TextContent @new, Models.TextContent old)
{
@new.StoreFiles();
((IPersistable)@new).OnSaving();
var command = dbCommands.Update(@new);
if (SQLCeTransactionUnit.Current != null)
{
SQLCeTransactionUnit.Current.RegisterCommand(command);
SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)@new).OnSaved(); });
}
else
{
SQLCeHelper.ExecuteNonQuery(@new.GetRepository().GetConnectionString(), command);
((IPersistable)@new).OnSaved();
}
}
示例14: Delete
public void Delete(Models.TextContent content)
{
var command = dbCommands.Delete(content);
if (SQLCeTransactionUnit.Current != null)
{
SQLCeTransactionUnit.Current.RegisterCommand(command);
SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { TextContentFileHelper.DeleteFiles(content); });
}
else
{
SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
TextContentFileHelper.DeleteFiles(content);
}
}
示例15: DeleteCategories
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
{
SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(),
categories.Select(it => dbCommands.DeleteCategory(content.GetRepository(), it)).ToArray());
}