本文整理汇总了C#中System.Db.Query方法的典型用法代码示例。如果您正苦于以下问题:C# Db.Query方法的具体用法?C# Db.Query怎么用?C# Db.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Db
的用法示例。
在下文中一共展示了Db.Query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public static async Task Send(Db db)
{
var host = HttpContext.Current?.Request.ServerVariables["HTTP_HOST"];
if (host == null || !host.Equals("jeegoordah.azurewebsites.net", StringComparison.InvariantCultureIgnoreCase))
{
throw new Exception($"Sending notifications is disabled for {host}");
}
var sendTasks = db.Query<Bro>()
.Where(x => x.Email != null)
.Where(x => x.Notifications.Count > 0)
.ToArray()
.Select(async bro =>
{
var message = new SendGridMessage
{
From = _from,
To = new[] {new MailAddress(bro.Email)},
Subject = "Jeegoordah notifications",
Text = GetContent(bro.Notifications),
Html = null,
};
_logger.I($"Sending {bro.Notifications.Count} notifications for {bro.Name}");
await _transport.DeliverAsync(message);
_logger.I($"Notifications for {bro.Name} sent");
});
await Task.WhenAll(sendTasks);
db.Query<Notification>().ForEach(db.Session.Delete);
_logger.I("Notifications deleted");
}
示例2: Main
private static void Main(string[] args)
{
var db = new Db(new MyConfig());
for (int i = 0; i < 500; i++)
{
db.Query<Employee>("select * from Employee where EmployeeId = /*id*/0", new {id = 1});
}
Console.WriteLine("Done");
}
示例3: AssertNameUnique
private bool AssertNameUnique(EventRest @event, Db db, out JsonResult result)
{
result = null;
bool conflict = @event.Id.HasValue
? db.Query<Event>().Any(e => e.Id != @event.Id.Value && e.Name == @event.Name)
: db.Query<Event>().Any(e => e.Name == @event.Name);
if (!conflict) return true;
Logger.E("Attempt to create duplicate event {0}", @event.Name);
result = Json(new {Field = "Name", Message = "Event with name {0} already exists.".F(@event.Name)});
Response.StatusCode = 400;
return false;
}
示例4: ExchangeRatesUpdater
private ExchangeRatesUpdater(Db db)
{
this.db = db;
byn = db.Query<Currency>().Where(c => c.Name == "BYN").First();
}