本文整理汇总了C#中DbSet.SearchAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DbSet.SearchAsync方法的具体用法?C# DbSet.SearchAsync怎么用?C# DbSet.SearchAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbSet
的用法示例。
在下文中一共展示了DbSet.SearchAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DbSetSearchAsyncTest
public async Task DbSetSearchAsyncTest()
{
//Arrange
var mockRestResponse = new Mock<IRestResponse>();
mockRestResponse.SetupGet(o => o.ResponseStatus).Returns(ResponseStatus.Completed);
mockRestResponse.SetupGet(o => o.StatusCode).Returns(HttpStatusCode.OK);
mockRestResponse.SetupGet(o => o.Content).Returns(@"{""elements"":[{
""contactId"": ""48620"",
""id"": ""10002"",
""fieldValues"": [
{
""id"": ""824"",
""value"": ""transxId12321321321321""
}
],
""name"": ""Bob Tester"",
""uri"": ""/data/customObject""
}]}
");
var mockRestClient = new Mock<IRestClient>();
mockRestClient.Setup(o => o.ExecuteTaskAsync(It.IsAny<IRestRequest>())).ReturnsAsync(mockRestResponse.Object);
var dbSet = new DbSet<MockDbsetWithDataContact>(mockRestClient.Object);
//Act
var contact = await dbSet.SearchAsync("Bob tester");
//Assert
Assert.AreEqual(1, contact.Count);
}
示例2: DbSetSearchAsyncResourceAttributeNullTest
public async Task DbSetSearchAsyncResourceAttributeNullTest()
{
//Arrange
var mockRestClient = new Mock<IRestClient>();
var dbSet = new DbSet<MockDbsetContact>(mockRestClient.Object);
//Act
await dbSet.SearchAsync("test");
//Assert - throws
}