Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit ccea1fe

Browse files
committed
Added BucketCount and Collation to Sql Server Create table
1 parent c1fcb02 commit ccea1fe

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ServiceStack.OrmLite.SqlServer/SqlServer2014OrmLiteDialectProvider.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,22 @@ public override string ToCreateTableStatement(Type tableType)
3939
if (columnDefinition == null)
4040
continue;
4141

42+
var collationAttribs = fieldDef.PropertyInfo.GetAttributes<SqlServerCollateAttribute>();
43+
if (collationAttribs.Count > 0)
44+
{
45+
columnDefinition += $" COLLATE {collationAttribs[0].collation}";
46+
}
47+
4248
if (isMemoryTable && fieldDef.IsPrimaryKey)
43-
columnDefinition += " NONCLUSTERED";
49+
{
50+
columnDefinition = columnDefinition.Replace("PRIMARY KEY", "PRIMARY KEY NONCLUSTERED");
51+
52+
var bucketCountAtribs = fieldDef.PropertyInfo.GetAttributes<SqlServerBucketCountAttribute>();
53+
if (bucketCountAtribs.Count > 0)
54+
{
55+
columnDefinition += $" HASH WITH (BUCKET_COUNT={bucketCountAtribs[0].count})";
56+
}
57+
}
4458

4559
if (sbColumns.Length != 0)
4660
sbColumns.Append(", \n ");

0 commit comments

Comments
 (0)