Esempio n. 1
0
        public static bool CreateColumn(this ITableTemplate template, Authentication authentication)
        {
            var columnName = RandomUtility.NextIdentifier();

            if (template.Contains(columnName) == true)
            {
                return(false);
            }

            var column = template.AddNew(authentication);

            column.SetName(authentication, columnName);

            if (template.PrimaryKey.Any() == false)
            {
                column.SetIsKey(authentication, true);
            }
            else if (template.Count == 0 && RandomUtility.Within(10))
            {
                column.SetIsKey(authentication, true);
                column.SetIsUnique(authentication, RandomUtility.Within(75));
            }

            if (RandomUtility.Within(75) == true)
            {
                column.SetTags(authentication, TagInfo.All);
            }
            else
            {
                column.SetTags(authentication, tags.Random());
            }

            if (RandomUtility.Within(75) == true)
            {
                column.SetDataType(authentication, CremaDataTypeUtility.GetBaseTypeNames().Random());
            }
            else
            {
                column.SetDataType(authentication, template.SelectableTypes.Random());
            }

            if (RandomUtility.Within(25) == true)
            {
                column.SetComment(authentication, RandomUtility.NextString());
            }

            if (CremaDataTypeUtility.CanUseAutoIncrement(column.DataType) == true)
            {
                column.SetAutoIncrement(authentication, RandomUtility.NextBoolean());
            }

            try
            {
                template.EndNew(authentication, column);
            }
            catch
            {
                return(false);
            }
            return(true);
        }
 public void Contains()
 {
     template.Contains(RandomUtility.NextIdentifier());
 }
 public static Task <bool> ContainsAsync(this ITableTemplate template, string columnName)
 {
     return(template.Dispatcher.InvokeAsync(() => template.Contains(columnName)));
 }