コード例 #1
0
        private static ILookup <int, PropertyPreValue> GetPreValues(string dataDir, ConnectionStringSettings connectionSetting)
        {
            List <DataTypePreValue> tList = new List <DataTypePreValue>();
            string getAllSql = Properties.Resources.CMSDataTypePreValuesSql;

            if (connectionSetting != null)
            {
                using (IDbConnection conn = GetDbConnection(dataDir, connectionSetting))
                {
                    conn.Open();

                    using (IDbCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = getAllSql;

                        using (IDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                DataTypePreValue t = new DataTypePreValue();

                                t.Alias      = reader["Alias"].ToString();
                                t.DataTypeId = (int)reader["DatatypeNodeId"];
                                t.Value      = reader["Value"].ToString();
                                tList.Add(t);
                            }
                        }
                    }
                }
            }

            return(tList.ToLookup(k => k.DataTypeId, v => (PropertyPreValue)v));
        }
コード例 #2
0
        internal ILookup <int, PropertyPreValue> GetPreValues()
        {
            if (_PreValues != null && _PreValues.Any())
            {
                return(_PreValues);
            }
            List <DataTypePreValue> tList = new List <DataTypePreValue>();
            string getAllSql = Properties.Resources.CMSDataTypePreValuesSql;

            using (IDbConnection conn = GetDbConnection())
            {
                conn.Open();

                using (IDbCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = getAllSql;

                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DataTypePreValue t = new DataTypePreValue();

                            t.Alias      = reader["Alias"].ToString();
                            t.DataTypeId = (int)reader["DatatypeNodeId"];
                            t.Value      = reader["Value"].ToString();
                            tList.Add(t);
                        }
                    }
                }
            }

            return(_PreValues = tList.ToLookup(k => k.DataTypeId, v => (PropertyPreValue)v));
        }