diff --git a/N.EntityFrameworkCore.Extensions.Test/N.EntityFrameworkCore.Extensions.Test.csproj b/N.EntityFrameworkCore.Extensions.Test/N.EntityFrameworkCore.Extensions.Test.csproj
index 9fcf3b4..bd6be52 100644
--- a/N.EntityFrameworkCore.Extensions.Test/N.EntityFrameworkCore.Extensions.Test.csproj
+++ b/N.EntityFrameworkCore.Extensions.Test/N.EntityFrameworkCore.Extensions.Test.csproj
@@ -2,7 +2,7 @@
net8.0
- 1.5.0
+
diff --git a/N.EntityFrameworkCore.Extensions/N.EntityFrameworkCore.Extensions.csproj b/N.EntityFrameworkCore.Extensions/N.EntityFrameworkCore.Extensions.csproj
index d2a4682..12a34ab 100644
--- a/N.EntityFrameworkCore.Extensions/N.EntityFrameworkCore.Extensions.csproj
+++ b/N.EntityFrameworkCore.Extensions/N.EntityFrameworkCore.Extensions.csproj
@@ -2,7 +2,7 @@
net8.0
- 8.0.0.0
+ 8.0.0.2
true
https://github.com/NorthernLight1/N.EntityFrameworkCore.Extensions/
Northern25
diff --git a/N.EntityFrameworkCore.Extensions/Sql/SqlBuilder.cs b/N.EntityFrameworkCore.Extensions/Sql/SqlBuilder.cs
index 2ec2140..21574f8 100644
--- a/N.EntityFrameworkCore.Extensions/Sql/SqlBuilder.cs
+++ b/N.EntityFrameworkCore.Extensions/Sql/SqlBuilder.cs
@@ -43,11 +43,12 @@ private void Initialize(string sqlText)
{
var declareParts = inputText.Substring(0, inputText.IndexOf(";")).Trim().Split(" ");
int sizeStartIndex = declareParts[1].IndexOf("(");
+ int sizeLength = declareParts[1].IndexOf(")") - (sizeStartIndex+1);
string dbTypeString = sizeStartIndex != -1 ? declareParts[1].Substring(0, sizeStartIndex) : declareParts[1];
SqlDbType dbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), dbTypeString, true);
int size = sizeStartIndex != -1 ?
- Convert.ToInt32(declareParts[1].Substring(sizeStartIndex).Replace(")", "")) : 0;
- string value = declareParts[3][0] == '\'' ? declareParts[3].Substring(1, declareParts[3].Length - 2) : declareParts[3];
+ Convert.ToInt32(declareParts[1].Substring(sizeStartIndex+1, sizeLength)) : 0;
+ string value = GetDeclareValue(declareParts[3]);
Parameters.Add(new SqlParameter(declareParts[0], dbType, size) { Value = value });
}
else
@@ -67,6 +68,23 @@ private void Initialize(string sqlText)
if (!string.IsNullOrEmpty(curClause))
Clauses.Add(SqlClause.Parse(curClause, sqlText.Substring(curClauseIndex)));
}
+
+ private string GetDeclareValue(string value)
+ {
+ if(value.StartsWith("'"))
+ {
+ return value.Substring(1, value.Length - 2);
+ }
+ else if (value.StartsWith("N'"))
+ {
+ return value.Substring(2, value.Length - 3);
+ }
+ else
+ {
+ return value;
+ }
+ }
+
public string Count()
{
return string.Format("SELECT COUNT(*) FROM ({0}) s", string.Join("\r\n", Clauses.Where(o => o.Name != "ORDER BY").Select(o => o.ToString())));