本文整理汇总了C#中Mapper.DeleteIf方法的典型用法代码示例。如果您正苦于以下问题:C# Mapper.DeleteIf方法的具体用法?C# Mapper.DeleteIf怎么用?C# Mapper.DeleteIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper.DeleteIf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteIf_Cql_Applied_True_Test
public void DeleteIf_Cql_Applied_True_Test()
{
var session = GetSession((q, args) => { }, TestDataHelper.CreateMultipleValuesRowSet(new[] { "[applied]" }, new[] { true }));
var mapper = new Mapper(session, new MappingConfiguration());
var appliedInfo = mapper.DeleteIf<Song>(Cql.New("WHERE id = ? IF title = ?", Guid.NewGuid(), "All of My love"));
Assert.True(appliedInfo.Applied);
Assert.Null(appliedInfo.Existing);
}
示例2: DeleteIf_Cql_Prepends_Test
public void DeleteIf_Cql_Prepends_Test()
{
string query = null;
var session = GetSession((q, args) => query = q, new RowSet());
var mapper = new Mapper(session, new MappingConfiguration());
mapper.DeleteIf<Song>(Cql.New("WHERE id = ? IF title = ?", Guid.NewGuid(), "All of My love"));
Assert.AreEqual("DELETE FROM Song WHERE id = ? IF title = ?", query);
}
示例3: DeleteIf_Cql_Applied_False_Test
public void DeleteIf_Cql_Applied_False_Test()
{
var session = GetSession((q, args) => { }, TestDataHelper.CreateMultipleValuesRowSet(new[] { "[applied]", "title" }, new object[] { false, "I Feel Free" }));
var mapper = new Mapper(session, new MappingConfiguration());
var appliedInfo = mapper.DeleteIf<Song>(Cql.New("WHERE id = ? IF title = ?", Guid.NewGuid(), "All of My love"));
Assert.False(appliedInfo.Applied);
Assert.NotNull(appliedInfo.Existing);
Assert.AreEqual("I Feel Free", appliedInfo.Existing.Title);
}
示例4: DeleteIf_Applied_Test
public void DeleteIf_Applied_Test()
{
var config = new MappingConfiguration()
.Define(new Map<Song>().PartitionKey(s => s.Id).TableName("song_delete_if"));
//Use linq to create the table
new Table<Song>(_session, config).Create();
var mapper = new Mapper(_session, config);
var song = new Song { Id = Guid.NewGuid(), Artist = "Cream", Title = "Crossroad", ReleaseDate = DateTimeOffset.Parse("1970/1/1") };
mapper.Insert(song);
//It should not apply it as the condition will NOT be satisfied
var appliedInfo = mapper.DeleteIf<Song>(Cql.New("WHERE id = ? IF title = ?", song.Id, "Crossroad2"));
Assert.False(appliedInfo.Applied);
Assert.NotNull(appliedInfo.Existing);
Assert.AreEqual("Crossroad", appliedInfo.Existing.Title);
//It should apply it as the condition will be satisfied
appliedInfo = mapper.DeleteIf<Song>(Cql.New("WHERE id = ? IF title = ?", song.Id, song.Title));
Assert.True(appliedInfo.Applied);
Assert.Null(appliedInfo.Existing);
}