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


C# DataStore.GetFilteredData方法代码示例

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


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

示例1: GetBaseData

        /// <summary>Get the base data that is in scope.</summary>
        public DataTable GetBaseData(string tableName)
        {
            if (tables.ContainsKey(tableName))
                return tables[tableName];

            else if (tableName != null)
            {
                Simulation parentSimulation = Apsim.Parent(this, typeof(Simulation)) as Simulation;
                Zone parentZone = Apsim.Parent(this, typeof(Zone)) as Zone;
                Experiment parentExperiment = Apsim.Parent(this, typeof(Experiment)) as Experiment;

                string baseFilter = null;
                // If the graph is in a zone then just graph the zone.
                if (parentZone != null && !(parentZone is Simulation))
                {
                    // in a zone.
                    baseFilter = string.Format("SimulationName='{0}' and ZoneName='{1}'", parentSimulation.Name, parentZone.Name);
                }
                else
                {
                    List<string> simulationNames = new List<string>();
                    if (parentSimulation != null)
                        simulationNames.Add(parentSimulation.Name);  // in a simulation.

                    else if (parentExperiment != null)
                        simulationNames.AddRange(parentExperiment.Names());

                    else
                    {
                        // Must be in a folder at the top level or at the top level of the .apsimx file.
                        IModel parentOfGraph = this.Parent;

                        // Look for experiments.
                        foreach (Experiment experiment in Apsim.ChildrenRecursively(parentOfGraph, typeof(Experiment)))
                            simulationNames.AddRange(experiment.Names());

                        // Look for simulations if we didn't find any experiments.
                        foreach (Simulation simulation in Apsim.ChildrenRecursively(parentOfGraph, typeof(Simulation)))
                        {
                            if (simulation.Parent is Experiment)
                            { }
                            else
                                simulationNames.Add(simulation.Name);
                        }
                    }

                    // convert simulationNames to a filter.
                    foreach (string simulationName in simulationNames)
                    {
                        if (baseFilter != null)
                            baseFilter += ",";
                        baseFilter += "'" + simulationName + "'";
                    }
                    baseFilter = "SimulationName IN (" + baseFilter + ")";
                }

                DataStore dataStore = new DataStore(this);
                DataTable data = dataStore.GetFilteredData(tableName, baseFilter);
                dataStore.Disconnect();
                tables.Add(tableName, data);
                return data;
            }

            return null;
        }
开发者ID:hut104,项目名称:ApsimX,代码行数:66,代码来源:Graph.cs


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