Skip to content

Commit

Permalink
switch to string.format
Browse files Browse the repository at this point in the history
  • Loading branch information
avi-berkowitz-zocdoc committed Dec 28, 2017
1 parent 474b0d9 commit 10c92bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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

0 comments on commit 10c92bc

Please sign in to comment.