Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to string.format #29

Merged
merged 1 commit into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions model/Models/Constraint.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;

namespace SchemaZen.Library.Models {
Expand Down Expand Up @@ -41,7 +42,7 @@ public string UniqueText {
public string ScriptCreate() {
if (Type == "CHECK") {
var notForReplicationOption = IsNotForReplication ? "NOT FOR REPLICATION" : "";
return $"CONSTRAINT [{Name}] CHECK {notForReplicationOption} {CheckConstraintExpression}";
return string.Format("CONSTRAINT [{0}] CHECK {1} {2}", Name, notForReplicationOption, CheckConstraintExpression);
}

if (Type == "INDEX") {
Expand Down
8 changes: 5 additions & 3 deletions model/Models/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ public void ImportData(string conn, string filename) {
var row = dt.NewRow();
var fields = (new String(line.ToArray())).Split(new[] { fieldSeparator }, StringSplitOptions.None);
if (fields.Length != dt.Columns.Count) {
var columnNames = dt.Columns.OfType<DataColumn>().Select(c => $" * {c.ColumnName} ({c.DataType})").ToArray();
var details = $"fields.Length: {fields.Length}, Columns.Count: {dt.Columns.Count}, Column Names:{Environment.NewLine}{string.Join(Environment.NewLine, columnNames)}";
throw new DataFileException($"Incorrect number of columns, {details}", filename, linenumber);
var columnNames = dt.Columns.OfType<DataColumn>().Select(c =>
string.Format(" * {0} ({1})", c.ColumnName, c.DataType)).ToArray();
var details = string.Format("fields.Length: {0}, Columns.Count: {1}, Column Names:{2}{3}", fields.Length,
dt.Columns.Count, Environment.NewLine, string.Join(Environment.NewLine, columnNames));
throw new DataFileException(string.Format("Incorrect number of columns, {0}", details), filename, linenumber);
}
for (var j = 0; j < fields.Length; j++) {
try {
Expand Down