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


C# IDatabase.Query方法代码示例

本文整理汇总了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;
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:12,代码来源:SimpleMembershipProvider.cs

示例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;
        }
开发者ID:throbbo,项目名称:ImportAccounts,代码行数:63,代码来源:TransactionReporter.cs


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