當前位置: 首頁>>代碼示例>>C#>>正文


C# Column.IsLengthDefined方法代碼示例

本文整理匯總了C#中NHibernate.Mapping.Column.IsLengthDefined方法的典型用法代碼示例。如果您正苦於以下問題:C# Column.IsLengthDefined方法的具體用法?C# Column.IsLengthDefined怎麽用?C# Column.IsLengthDefined使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NHibernate.Mapping.Column的用法示例。


在下文中一共展示了Column.IsLengthDefined方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MakeDataProperty

        /// <summary>
        /// Make data property metadata for the entity
        /// </summary>
        /// <param name="propName">name of the property on the server</param>
        /// <param name="typeName">data type of the property, e.g. Int32</param>
        /// <param name="isNullable">whether the property is nullable in the database</param>
        /// <param name="col">Column object, used for maxLength and defaultValue</param>
        /// <param name="isKey">true if this property is part of the key for the entity</param>
        /// <param name="isVersion">true if this property contains the version of the entity (for a concurrency strategy)</param>
        /// <returns></returns>
        private Dictionary<string, object> MakeDataProperty(string propName, string typeName, bool isNullable, Column col, bool isKey, bool isVersion)
        {
            var dmap = new Dictionary<string, object>();
            dmap.Add("nameOnServer", propName);
            dmap.Add("dataType", typeName);
            dmap.Add("isNullable", isNullable);

            if (col != null && col.IsLengthDefined())
            {
                dmap.Add("maxLength", col.Length);
            }
            if (col != null && col.DefaultValue != null)
            {
                dmap.Add("defaultValue", col.DefaultValue);
            }

            if (isKey)
            {
                dmap.Add("isPartOfKey", true);
            }
            if (isVersion)
            {
                dmap.Add("concurrencyMode", "Fixed");
            }
            return dmap;
        }
開發者ID:Vintharas,項目名稱:Breeze,代碼行數:36,代碼來源:NHBreezeMetadata.cs

示例2: MakeDataProperty

        /// <summary>
        /// Make data property metadata for the entity
        /// </summary>
        /// <param name="propName">name of the property on the server</param>
        /// <param name="typeName">data type of the property, e.g. Int32</param>
        /// <param name="isNullable">whether the property is nullable in the database</param>
        /// <param name="col">Column object, used for maxLength and defaultValue</param>
        /// <param name="isKey">true if this property is part of the key for the entity</param>
        /// <param name="isVersion">true if this property contains the version of the entity (for a concurrency strategy)</param>
        /// <returns></returns>
        private Dictionary<string, object> MakeDataProperty(string propName, string typeName, bool isNullable, Column col, bool isKey, bool isVersion)
        {
            string newType;
            typeName = (BreezeTypeMap.TryGetValue(typeName, out newType)) ? newType : typeName;

            var dmap = new Dictionary<string, object>();
            dmap.Add("nameOnServer", propName);
            dmap.Add("dataType", typeName);
            dmap.Add("isNullable", isNullable);

            if (col != null && col.DefaultValue != null)
            {
                dmap.Add("defaultValue", col.DefaultValue);
            }
            if (isKey)
            {
                dmap.Add("isPartOfKey", true);
            }
            if (isVersion)
            {
                dmap.Add("concurrencyMode", "Fixed");
            }

            var validators = new List<Dictionary<string, string>>();

            if (!isNullable)
            {
                validators.Add(new Dictionary<string, string>() {
                    {"name", "required" },
                });
            }
            if (col != null && col.IsLengthDefined())
            {
                dmap.Add("maxLength", col.Length);

                validators.Add(new Dictionary<string, string>() {
                    {"maxLength", col.Length.ToString() },
                    {"name", "maxLength" }
                });
            }

            string validationType;
            if (ValidationTypeMap.TryGetValue(typeName, out validationType))
            {
                validators.Add(new Dictionary<string, string>() {
                    {"name", validationType },
                });
            }

            if (validators.Any())
                dmap.Add("validators", validators);

            return dmap;
        }
開發者ID:Rickinio,項目名稱:breeze.server.net,代碼行數:64,代碼來源:NHBreezeMetadata.cs


注:本文中的NHibernate.Mapping.Column.IsLengthDefined方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。