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


C# IDatabase.Fetch方法代码示例

本文整理汇总了C#中IDatabase.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.Fetch方法的具体用法?C# IDatabase.Fetch怎么用?C# IDatabase.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDatabase的用法示例。


在下文中一共展示了IDatabase.Fetch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getRolesHierarchyRecursive

        private void getRolesHierarchyRecursive(IDatabase db, Role parentRole)
        {
            if (parentRole == null)
                return;


            parentRole.juniorRolesList = db.Fetch<Role>(
                                "SELECT Role.* FROM Role "
                                + "INNER JOIN RoleHierarchy ON Role.roleId = RoleHierarchy.juniorRoleId "
                                + "WHERE RoleHierarchy.roleId = @0;",
                                parentRole.RoleId
            );

            foreach (Role juniorRole in parentRole.juniorRolesList)
                getRolesHierarchyRecursive(db, juniorRole);

        }
开发者ID:rjcanto,项目名称:SI.1314i,代码行数:17,代码来源:PDP.cs

示例2: GetTransactionsAllReport

        public TransactionsAllReport GetTransactionsAllReport(IDatabase db, int companyId, DateTime from, DateTime to)
        {
            var transactions = db.Fetch<TransactionView>(@"
            select *
            from transactionview v
            inner join runningbalance rb on rb.transactionid = v.transactionid
            where  v.companyid = @0", companyId).OrderBy(x => x.Account).ThenBy(y => y.TransactionDate).ThenBy(z => z.TransactionId).ToList();

            var report = new TransactionsAllReport(from, to);

            var account = "";
            foreach (var t in transactions)
            {
                var currentBalance = 0m;
                var balDispaly = (account != t.AccountNumber) ? (t.Balance + t.Amount).ToString("C") : "";
                account = t.AccountNumber;

                report.TransactionReportItems.Add(new TransactionReportItem
                {
                    BankAccount = t.AccountNumber,
                    Amount = t.Amount,
                    BalanceAfter = t.Balance,
                    OpeningBalance = t.Balance + t.Amount,
                    OpeningBalanceDisplay = balDispaly,
                    Category = t.Category,
                    TransactionDate = t.TransactionDate,
                    TransactionDateStr = t.TransactionDate.ToString("yyyy-MM-dd"),
                    TransactionId = t.TransactionId,
                    Quarter = GetQuarter(t.TransactionDate)
                });
            }

            return report;
        }
开发者ID:throbbo,项目名称:ImportAccounts,代码行数:34,代码来源:TransactionReporter.cs

示例3: getRolesHierarchy

        //Support method to retrieve Roles Hierarchy from database
        private void getRolesHierarchy(IDatabase db)
        {
            listRoles = db.Fetch<Role>("SELECT Role.* FROM Role");

            foreach (Role parentRole in listRoles)
                getRolesHierarchyRecursive(db, parentRole);

        }
开发者ID:rjcanto,项目名称:SI.1314i,代码行数:9,代码来源:PDP.cs

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