Пример #1
0
        public string BuildCreateQuery()
        {
            var fields = new StringBuilder(Columns.Values.BuildCharacterSeparatedString(column =>
            {
                var columnData   = column.Item1;
                var propertyInfo = column.Item2;
                var mappedType   = MapType(propertyInfo, columnData);

                var nullText = columnData.Nullable ? string.Empty : " NOT NULL";
                return($"{columnData.ResolveName(propertyInfo)} {mappedType}{nullText}");
            }));

            if (Keys.Count != 0)
            {
                var keyFields = Keys.BuildCharacterSeparatedString();
                fields.Append($", PRIMARY KEY({keyFields})");
            }

            return($"CREATE TABLE {TableName} ({fields});");
        }