当前位置: 首页>>代码示例>>C#>>正文


C# Mapper.DeleteIf方法代码示例

本文整理汇总了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);
 }
开发者ID:alprema,项目名称:csharp-driver,代码行数:8,代码来源:DeleteTests.cs

示例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);
 }
开发者ID:alprema,项目名称:csharp-driver,代码行数:8,代码来源:DeleteTests.cs

示例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);
 }
开发者ID:alprema,项目名称:csharp-driver,代码行数:9,代码来源:DeleteTests.cs

示例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);
 }
开发者ID:Virus-X,项目名称:csharp-driver,代码行数:19,代码来源:Delete.cs


注:本文中的Mapper.DeleteIf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。