/// <summary>
        /// 将所有行的单元格信息按照列定义,形成每一行的Values的内容
        /// </summary>
        /// <param name="view">ROLE_PROPERTIES_CELLS表的每一行信息,每一行表示一个单元格的值</param>
        /// <param name="definition">列定义信息</param>
        /// <returns></returns>
        internal static Dictionary <int, SOARolePropertyValueCollection> LoadAndGroup(DataView view, SOARolePropertyDefinitionCollection definition)
        {
            Dictionary <int, SOARolePropertyValueCollection> result = new Dictionary <int, SOARolePropertyValueCollection>();

            foreach (DataRowView drv in view)
            {
                SOARolePropertyDefinition rpd = definition[drv["PROPERTY_NAME"].ToString()];

                //如果找到了列定义...
                if (rpd != null)
                {
                    SOARolePropertyValue pv = new SOARolePropertyValue(rpd);

                    pv.Value = drv["STRING_VALUE"].ToString();

                    object objRowNumber = drv["PROPERTIES_ROW_ID"];
                    int    rowNumber    = 0;

                    if (objRowNumber is int)
                    {
                        rowNumber = (int)objRowNumber;
                    }

                    SOARolePropertyValueCollection values = null;

                    if (result.TryGetValue(rowNumber, out values) == false)
                    {
                        values = new SOARolePropertyValueCollection();
                        result.Add(rowNumber, values);
                    }

                    values.Add(pv);
                }
            }

            foreach (KeyValuePair <int, SOARolePropertyValueCollection> kp in result)
            {
                kp.Value.Sort((v1, v2) => v1.Column.SortOrder - v2.Column.SortOrder);
            }

            return(result);
        }
        /// <summary>
        /// 根据RoleID加载行信息
        /// </summary>
        /// <param name="roleID"></param>
        /// <param name="role"></param>
        /// <param name="definition">列定义</param>
        /// <returns></returns>
        public SOARolePropertyRowCollection LoadByRoleID(string roleID, IRole role, SOARolePropertyDefinitionCollection definition)
        {
            roleID.CheckStringIsNullOrEmpty("roleID");
            definition.NullCheck("definition");

            StringBuilder strB = new StringBuilder();

            strB.AppendFormat("SELECT * FROM WF.ROLE_PROPERTIES_ROWS WHERE {0} ORDER BY ROW_NUMBER", roleID.ToRoleIDCriteria());

            strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

            strB.AppendFormat("SELECT * FROM WF.ROLE_PROPERTIES_CELLS WHERE {0} ORDER BY PROPERTIES_ROW_ID", roleID.ToRoleIDCriteria());

            SOARolePropertyRowCollection result = new SOARolePropertyRowCollection(role);

            using (TransactionScope scope = TransactionScopeFactory.Create(TransactionScopeOption.Suppress))
            {
                DataSet ds = DbHelper.RunSqlReturnDS(strB.ToString(), GetConnectionName());
                Dictionary <int, SOARolePropertyValueCollection> propertyValues = SOARolePropertyValueCollection.LoadAndGroup(ds.Tables[1].DefaultView, definition);

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    SOARolePropertyRow property = new SOARolePropertyRow(role);

                    ORMapping.DataRowToObject(row, property);

                    SOARolePropertyValueCollection values = null;

                    if (propertyValues.TryGetValue(property.RowNumber, out values))
                    {
                        property.Values.CopyFrom(values);
                    }

                    result.Add(property);
                }
            }

            return(result);
        }