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


C# OrmliteConnection.Query方法代码示例

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


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

示例1: GetMerchant

 public ActionResult GetMerchant(string text)
 {
     using (var dbConn = new OrmliteConnection().openConn())
     {
         var data = new List<DC_OCM_Merchant>();
         if (text.Length >= 3)
         {
             data = dbConn.Query<DC_OCM_Merchant>("SELECT TOP 5 * FROM DC_OCM_Merchant WHERE MerchantName COLLATE Latin1_General_CI_AI LIKE N'%" + text + "%'");
         }
         return Json(data, JsonRequestBehavior.AllowGet);
     }
 }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:12,代码来源:AD_OrderController.cs

示例2: Export

        public ActionResult Export([DataSourceRequest]DataSourceRequest request)
        {
            if (userAsset["Export"])
            {
                using (var dbConn = new OrmliteConnection().openConn())
                {
                    //using (ExcelPackage excelPkg = new ExcelPackage())
                    FileInfo fileInfo = new FileInfo(Server.MapPath(@"~\ExportTemplate\DanhMucAnPham.xlsx"));
                    var excelPkg = new ExcelPackage(fileInfo);

                    string fileName = "ThongTinKho_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
                    string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                    var data = new List<Products>();
                    if (request.Filters.Any())
                    {
                        var where = new KendoApplyFilter().ApplyFilter(request.Filters[0], "data.");
                        //data = dbConn.Select<Products>(where);
                        data = dbConn.Query<Products>("p_SelectDC_AD_Item_Export", new { WhereCondition = where}, commandType:System.Data.CommandType.StoredProcedure).ToList();
                    }
                    else
                    {
                        //data = dbConn.Select<Products>();
                        data = dbConn.Query<Products>("p_SelectDC_AD_Item_Export", new { WhereCondition = "1=1" }, commandType: System.Data.CommandType.StoredProcedure).ToList();
                    }

                    ExcelWorksheet expenseSheet = excelPkg.Workbook.Worksheets["Data"];

                    int rowData = 1;

                    foreach (var item in data)
                    {
                        int i = 1;
                        rowData++;
                        expenseSheet.Cells[rowData, i++].Value = item.Code;
                        expenseSheet.Cells[rowData, i++].Value = item.Name;
                        expenseSheet.Cells[rowData, i++].Value = item.Size;
                        expenseSheet.Cells[rowData, i++].Value = item.VATPrice;
                        expenseSheet.Cells[rowData, i++].Value = item.Type;
                        expenseSheet.Cells[rowData, i++].Value = item.UnitName+"/"+item.UnitID;
                        expenseSheet.Cells[rowData, i++].Value = item.WHName +"/"+item.WHID;
                        expenseSheet.Cells[rowData, i++].Value = item.WHLName + "/" +item.WHLID;
                        expenseSheet.Cells[rowData, i++].Value = item.ShapeTemplate;
                        if (item.Status == true)
                        {
                            expenseSheet.Cells[rowData, i++].Value = "Đang hoạt động";
                        }
                        else
                        {
                            expenseSheet.Cells[rowData, i++].Value = "Ngưng hoạt động";
                        }
                        expenseSheet.Cells[rowData, i++].Value = item.CreatedBy;
                        expenseSheet.Cells[rowData, i++].Value = item.CreatedAt;
                        expenseSheet.Cells[rowData, i++].Value = item.UpdatedBy;
                        if (item.UpdatedAt != DateTime.Parse("1900-01-01"))
                        {
                            expenseSheet.Cells[rowData, i++].Value = item.UpdatedAt;
                        }
                        else
                        {
                            expenseSheet.Cells[rowData, i++].Value = "";
                        }
                        //expenseSheet.Cells[rowData, i++].Value = item.RowLastUpdatedTime;
                    }
                    expenseSheet = excelPkg.Workbook.Worksheets["Warehouse"];
                    var listWH = dbConn.Select<WareHouse>("SELECT * FROM WareHouse WHERE Status = 1");
                    rowData = 1;
                    foreach (var item in listWH)
                    {
                        int i = 1;
                        rowData++;
                        expenseSheet.Cells[rowData, i++].Value = item.WHName + "/" + item.WHID;
                    }
                    expenseSheet = excelPkg.Workbook.Worksheets["Location"];
                    var listWHL = dbConn.Select<WareHouseLocation>("SELECT * FROM WareHouseL WHERE Status = 1");
                    rowData = 1;
                    foreach (var item in listWHL)
                    {
                        int i = 1;
                        rowData++;
                        expenseSheet.Cells[rowData, i++].Value = item.WHLName + "/" + item.WHLID;
                    }
                    expenseSheet = excelPkg.Workbook.Worksheets["Unit"];
                    var listUnit = dbConn.Select<DC_AD_Unit>("SELECT * FROM DC_AD_Unit WHERE Status = 1");
                    rowData = 1;
                    foreach (var item in listUnit)
                    {
                        int i = 1;
                        rowData++;
                        expenseSheet.Cells[rowData, i++].Value = item.UnitName + "/" + item.UnitID;
                    }

                    MemoryStream output = new MemoryStream();
                    excelPkg.SaveAs(output);
                    output.Position = 0;
                    return File(output.ToArray(), contentType, fileName);
                }
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:kenvinnguyen,项目名称:SES,代码行数:101,代码来源:ListPublicationController.cs

示例3: GetItem

 public ActionResult GetItem(string text)
 {
     using (var dbConn = new OrmliteConnection().openConn())
     {
         var data = new List<Products>();
         if (text.Length >= 3)
         {
             data = dbConn.Query<Products>("SELECT TOP 5 Name, Code, size FROM DC_AD_Items WHERE Name COLLATE Latin1_General_CI_AI LIKE N'%" + text + "%'");
         }
         return Json(data, JsonRequestBehavior.AllowGet);
     }
 }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:12,代码来源:AD_OrderController.cs


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