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


C# IRepository.ExecuteCommand方法代码示例

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


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

示例1: ByGridFasion

        private void ByGridFasion(StreamWriter wr1, StreamWriter wr2, StreamWriter wr3, IRepository<DataAccess.DFOdata> dfoDataRepository)
        {
            Console.Write("Processing ..\n");
            var rectArea = GetRectArea(dfoDataRepository);
            var selectedPointsStr = "";
            var cellCenterStr = "";
            var nanCellStr = "";
            var insertStatement = "Insert into dbo.Cells(X,Y,U,V) ";
            var totalCell = 0;
            var startTime = DateTime.Now;
            double distanceBetween2AdjacentCellCenterPoint = 2 * HalfOfEachCellArea;

            for (double y = rectArea.MaxY, i = 0.0; y >= rectArea.MinY; y = y - distanceBetween2AdjacentCellCenterPoint, i ++)
            {
                for (double x = rectArea.MinX, j = 0.0; x <= rectArea.MaxX; x = x + distanceBetween2AdjacentCellCenterPoint, j ++)
                {
                    var adjacentCell = new GridCell(x,y);
                    var sqlQuery = string.Format("Select * from DFOdata where X >= {0} and X <= {1} and Y >= {2} and Y <= {3}",
                                                 adjacentCell.X - HalfOfEachCellArea,
                                                 adjacentCell.X + HalfOfEachCellArea,
                                                 adjacentCell.Y - HalfOfEachCellArea,
                                                 adjacentCell.Y + HalfOfEachCellArea);
                    var dfoDataPoints = dfoDataRepository.ExecuteCommand<DataAccess.DFOdata>(sqlQuery);
                    var uCompSum = 0.0;
                    var vCompSum = 0.0;

                    foreach (var dfoDataPoint in dfoDataPoints)
                    {
                        selectedPointsStr += string.Format("{0},{1},{2},{3}\n", dfoDataPoint.X, dfoDataPoint.Y, dfoDataPoint.U, dfoDataPoint.V);
                        wr1.WriteLine("{0},{1},{2},{3}", dfoDataPoint.X, dfoDataPoint.Y, dfoDataPoint.U, dfoDataPoint.V);
                        uCompSum += dfoDataPoint.U;
                        vCompSum += dfoDataPoint.V;
                    }
                    var totalDataPoint = dfoDataPoints.Count;
                    double uComp = uCompSum / totalDataPoint;
                    double vComp = vCompSum / totalDataPoint;
                    if (!Double.IsNaN(uComp) && !Double.IsNaN(vComp))
                    {
                        cellCenterStr += string.Format("{0},{1},{2},{3}\n", adjacentCell.X, adjacentCell.Y, uComp, vComp);
                        var cellX = Convert.ToInt32(i);
                        var cellY = Convert.ToInt32(j);

                        if (totalCell == 0)
                            insertStatement += string.Format("SELECT {0}, {1}, {2}, {3}", cellY , cellX, uComp, vComp);
                        else
                            insertStatement += string.Format("UNION ALL SELECT {0}, {1}, {2}, {3}", cellY, cellX, uComp, vComp);
                        totalCell++;
                        Console.Write(string.Format("{0} {1}\n", i, j));
                    }
                    else
                    {
                        nanCellStr += string.Format("{0},{1},{2},{3}\n", adjacentCell.X, adjacentCell.Y, uComp, vComp);
                    }
                    //Console.Write("Total {0} poins for cell {1},{2}.\n", totalDataPoint, adjacentCell.X, adjacentCell.Y);

                }
                //if(Convert.ToInt32(i) == 1)
                //{
                //    break;
                //}

            }

            //dfoDataRepository.ExecuteCommandDirectly(insertStatement);

            wr1.Write(selectedPointsStr);
            wr2.Write(cellCenterStr);
            wr3.Write(nanCellStr);

            var currentTime = DateTime.Now;
            var diff = currentTime.Subtract(startTime).TotalSeconds;
            Console.Write("Done..\n Timing: {0}",diff);
        }
开发者ID:kolokolca,项目名称:Searistica,代码行数:73,代码来源:DFOdataProcessor.cs

示例2: BySpiralFasion

 private void BySpiralFasion(StreamWriter wr1, StreamWriter wr2, IRepository<DataAccess.DFOdata> dfoDataRepository)
 {
     var fixedCenterCell = new GridCell(0.0, 0.0);
     for (int nLayer = 1; nLayer <= 55; nLayer++)
     {
         var adjacentCells = GetNthSurroundingCellsFromCenterCell(fixedCenterCell, nLayer);
         foreach (var adjacentCell in adjacentCells)
         {
             Console.WriteLine(string.Format("{0},{1}", adjacentCell.X, adjacentCell.Y));
         }
         Console.Write(string.Format("Toal adjacent: {0}\n", adjacentCells.Count));
         foreach (var adjacentCell in adjacentCells)
         {
             var sqlQuery = string.Format("Select * from DFOdata where X >= {0} and X <= {1} and Y >= {2} and Y <= {3}",
                                          adjacentCell.X - HalfOfEachCellArea,
                                          adjacentCell.X + HalfOfEachCellArea,
                                          adjacentCell.Y - HalfOfEachCellArea,
                                          adjacentCell.Y + HalfOfEachCellArea);
             var dfoDataPoints = dfoDataRepository.ExecuteCommand<DataAccess.DFOdata>(sqlQuery);
             var uCompSum = 0.0;
             var vCompSum = 0.0;
             foreach (var dfoDataPoint in dfoDataPoints)
             {
                 wr1.WriteLine("{0},{1},{2},{3}", dfoDataPoint.X, dfoDataPoint.Y, dfoDataPoint.U, dfoDataPoint.V);
                 uCompSum += dfoDataPoint.U;
                 vCompSum += dfoDataPoint.V;
             }
             var totalDataPoint = dfoDataPoints.Count;
             double uComp = uCompSum / totalDataPoint;
             double vComp = vCompSum / totalDataPoint;
             //if (!Double.IsNaN(uComp) && !Double.IsNaN(vComp))
             //{
             wr2.WriteLine("{0},{1},{2},{3}", adjacentCell.X, adjacentCell.Y, uComp, vComp);
             //}
             //Console.Write("Total {0} poins for cell {1},{2}.\n", totalDataPoint, adjacentCell.X, adjacentCell.Y);
         }
         Console.WriteLine("--------------------\n");
     }
 }
开发者ID:kolokolca,项目名称:Searistica,代码行数:39,代码来源:DFOdataProcessor.cs

示例3: GetRectArea

 public RectArea GetRectArea(IRepository<DataAccess.DFOdata> dfoDataRepository)
 {
     const string sqlQuery = "select max(X) as MaxX, min(X) as MinX, max(Y) as MaxY, min(Y) as MinY from dbo.DFOdata";
     var rectArea = dfoDataRepository.ExecuteCommand<RectArea>(sqlQuery);
     if (rectArea == null)
         throw new Exception("Can't get the rect area !!");
     return rectArea.ElementAt(0);
 }
开发者ID:kolokolca,项目名称:Searistica,代码行数:8,代码来源:DFOdataProcessor.cs


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