초기커밋
This commit is contained in:
39
UGQDataAccess/Repository/NpcNameRepository.cs
Normal file
39
UGQDataAccess/Repository/NpcNameRepository.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MongoDB.Driver;
|
||||
using UGQDatabase.Models;
|
||||
using UGQDataAccess.Settings;
|
||||
using ServerCommon.UGQ;
|
||||
|
||||
namespace UGQDataAccess.Repository
|
||||
{
|
||||
public class NpcNameRepository : BaseRepository<NpcNameEntity>
|
||||
{
|
||||
private const string CollectionName = "NpcName";
|
||||
|
||||
public NpcNameRepository(IMongoClient mongoClient, IOptions<UGQDatabaseSettings> settings) :
|
||||
base(mongoClient, settings.Value.DatabaseName, CollectionName)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task upsertNpcName(int npcId, TextEntity npcName)
|
||||
{
|
||||
var filter = Builders<NpcNameEntity>.Filter.Eq(x => x.NpcId, npcId);
|
||||
|
||||
var update = Builders<NpcNameEntity>.Update
|
||||
.Set(x => x.NpcName, npcName);
|
||||
|
||||
var option = new UpdateOptions
|
||||
{
|
||||
IsUpsert = true,
|
||||
};
|
||||
|
||||
await Collection.UpdateOneAsync(filter, update, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user