Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ public virtual void Apply(AssociationType item, DbModel model)

private static IndexAnnotation CreateIndexAnnotation(string tableName, string propertyName, int count)
{
var indexName = IndexNameCreator.CreateName(tableName, propertyName);

// If there are two Indicies on the same property, the count is added.
// In SQLite an Index name must be global unique.
// To be honest, it should never happen. But because its possible by using the API, it should be covered.
if (count > 0)
{
indexName = String.Format(CultureInfo.InvariantCulture, "{0}_{1}", indexName, count);
}
// If there are two indices on the same property, the count is appended.
// In SQLite an index name must be globally unique.
// To be honest, it should never happen. But because it is possible via the API, it is covered.
// The suffix is folded in before escaping so it stays inside the quoted identifier;
// IndexNameCreator.CreateName returns an already-escaped name.
string uniquePropertyName = count > 0
? String.Format(CultureInfo.InvariantCulture, "{0}_{1}", propertyName, count)
: propertyName;

var indexName = IndexNameCreator.CreateName(tableName, uniquePropertyName);
var indexAttribute = new IndexAttribute(indexName);
return new IndexAnnotation(indexAttribute);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ internal class AssociationTypeContainer

public AssociationTypeContainer(IEnumerable<AssociationType> associationTypes, EntityContainer container)
{
sqliteAssociationTypes = associationTypes.Select(associationType => new SqliteAssociationType(associationType, container));
// Materialize once. GetAssociationTypes is called per entity set, so a deferred query
// would rebuild every SqliteAssociationType (and its entity-set lookups) on each call.
sqliteAssociationTypes = associationTypes.Select(associationType => new SqliteAssociationType(associationType, container)).ToList();
}

public IEnumerable<SqliteAssociationType> GetAssociationTypes(string entitySetName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static string GetDataSource(string connectionString)
IDictionary<string, string> strings = ParseConnectionString(connectionString);
if (strings.ContainsKey(DataSourceToken))
{
var path = ExpandDataDirectory(ParseConnectionString(connectionString)[DataSourceToken]);
var path = ExpandDataDirectory(strings[DataSourceToken]);
return path.Trim('"');
}

Expand Down