本文整理汇总了C#中IDatabase.Query方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.Query方法的具体用法?C# IDatabase.Query怎么用?C# IDatabase.Query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.Query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHashedPassword
private string GetHashedPassword(IDatabase db, int userId)
{
var pwdQuery = db.Query(@"SELECT m.[Password] " +
@"FROM " + MembershipTableName + " m, " + SafeUserTableName + " u " +
@"WHERE m.UserId = " + userId + " AND m.UserId = u." + SafeUserIdColumn).ToList();
// REVIEW: Should get exactly one match, should we throw if we get > 1?
if (pwdQuery.Count != 1)
{
return null;
}
return pwdQuery[0].Password;
}
示例2: GetTransactionReport
public TransactionReport GetTransactionReport(IDatabase db, int companyId, DateTime from, DateTime to)
{
var bankAccounts = db.Query<BankAccount>().Where(x => x.CompanyId == companyId).ToList();
var transactions = db.Fetch<TransactionView>(@"select * from transactionview v
where exists(
select * from bankaccounts b where b.companyid = @0 and b.Accountnumber = v.AccountNumber )",
companyId).ToList();
var report = new TransactionReport(from, to);
var quarters = QuarterHelper.GetQuarters(from, to);
foreach (var quarter in quarters)
{
var reportQuarter = new TransactionReportQuarter {Quarter = quarter};
foreach (var account in bankAccounts)
{
var currentBalance = 0m;
if (from <= reportQuarter.Quarter.StartDate && to >= reportQuarter.Quarter.EndDate)
{
currentBalance = account.Openingbalance;
reportQuarter.TransactionReportItems.Add(new TransactionReportItem
{
BankAccount = account.Accountnumber,
Amount = currentBalance,
BalanceAfter = currentBalance,
TransactionDate = account.Openingbalancedate,
TransactionDateStr = account.Openingbalancedate.FormatStandardStr(),
Line = "Opening Balance as at " + account.Openingbalancedate.ToString("D")
});
}
foreach (var transaction in transactions.Where(x => x.AccountNumber == account.Accountnumber && x.TransactionDate >= reportQuarter.Quarter.StartDate && x.TransactionDate <= reportQuarter.Quarter.EndDate))
{
reportQuarter.TransactionReportItems.Add(new TransactionReportItem
{
BankAccount = account.Accountnumber,
Category = transaction.Account,
Amount = transaction.Amount,
BalanceAfter = currentBalance - transaction.Amount,
TransactionDate = transaction.TransactionDate,
TransactionDateStr =
(transaction.TransactionDate == new DateTime(1, 1, 1)
? ""
: transaction.TransactionDate.ToString("yyyy-MM-dd")),
Line = transaction.Description
});
reportQuarter.Balance += transaction.Amount;
reportQuarter.TotalForQuarter += transaction.Amount;
reportQuarter.TotalTransactions++;
}
report.Quarters.Add(reportQuarter);
}
}
return report;
}