Skip to content

Commit

Permalink
SQL Server verify index bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke committed Feb 27, 2018
1 parent f6032ec commit 325d3ab
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 8 deletions.
3 changes: 2 additions & 1 deletion SQL Server/SqlServerDataStore.cs
Expand Up @@ -678,7 +678,8 @@ protected override string VerifyIndex(string entityName, string fieldName, Field
var sql = string.Format("SELECT COUNT(*) FROM sys.indexes WHERE name = '{0}' AND object_id = OBJECT_ID('dbo.{1}')", indexName, entityName);
command.CommandText = sql;

var i = (long)command.ExecuteScalar();
var idx = command.ExecuteScalar();
var i = Convert.ToInt64(idx);

if (i == 0)
{
Expand Down
4 changes: 2 additions & 2 deletions Shared/OpenNETCF.ORM.Version.cs
Expand Up @@ -9,5 +9,5 @@
[assembly: AssemblyProduct("OpenNETCF.ORM")]
[assembly: AssemblyCopyright("Copyright © Chris Tacke 2010-2017")]

[assembly: AssemblyVersion("1.0.17254.0")]
[assembly: AssemblyFileVersion("1.0.17254.0")]
[assembly: AssemblyVersion("1.0.18058.0")]
[assembly: AssemblyFileVersion("1.0.18058.0")]
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenNETCF.ORM.SqlServer.Integration.Test.Entities
{
public abstract class PublishedEntityBase
{
public PublishedEntityBase()
{
}

public PublishedEntityBase(Guid publishID, int clientID, int portfolioID, int engineID)
{
if (publishID == Guid.Empty)
{
this.PublishID = Guid.NewGuid();
}
else
{
this.PublishID = publishID;
}

RecordDateUtc = DateTime.Now.ToUniversalTime();

this.EngineID = engineID;
this.ClientID = clientID;
this.PortfolioID = portfolioID;
}

[Field(IsPrimaryKey = true)]
public Guid PublishID { get; set; }

[Field]
public int EngineID { get; set; }

/// <summary>
/// Time recorded at the building
/// </summary>
[Field(SearchOrder = FieldSearchOrder.Descending)]
public DateTime RecordDateUtc { get; set; }

/// <summary>
/// Time it was stored at the server
/// </summary>
[Field]
public DateTime StoredDateUtc { get; set; }

[Field(SearchOrder = FieldSearchOrder.Ascending)]
public int ClientID { get; set; }

[Field(SearchOrder = FieldSearchOrder.Ascending)]
public int PortfolioID { get; set; }
}
}
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenNETCF.ORM.SqlServer.Integration.Test.Entities
{
public enum HVACControlState
{
Heating,
Cooling
}

[Entity(KeyScheme = KeyScheme.GUID)]
public class PublishedTenantApartmentState : PublishedEntityBase
{
public PublishedTenantApartmentState()
{
}

/// <summary>
/// Foreign-key to the PublishedTenenantBuildingState
/// </summary>
[Field]
public Guid PublishedBuildingStateID { get; set; }

[Field]
public string ApartmentName { get; set; }

/// <summary>
/// Last time the apartment thermostat was contacted
/// </summary>
[Field]
public DateTime LastContact { get; set; }

[Field]
public HVACControlState ControlState { get; set; }

[Field]
public bool Occupied { get; set; }

[Field]
public double SpaceTemperature { get; set; }

[Field]
public double? SupplyTemperature { get; set; }

[Field]
public double? ReturnTemperature { get; set; }

[Field]
public double SetPoint { get; set; }

[Field]
public double HeatDeadband { get; set; }

[Field]
public double CoolDeadband { get; set; }
}
}
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenNETCF.ORM.SqlServer.Integration.Test.Entities
{
[Entity(KeyScheme = KeyScheme.GUID)]
public class PublishedTenantBuildingState : PublishedEntityBase
{
public PublishedTenantBuildingState()
{
}

[Field]
public double OutsideTemperature { get; set; }
[Field]
public double UnoccupiedSetPoint { get; set; }
[Field]
public double UnoccupiedHeatDeadband { get; set; }
[Field]
public double UnoccupiedCoolDeadband { get; set; }
}
}
Expand Up @@ -65,6 +65,9 @@
</Choose>
<ItemGroup>
<Compile Include="Entities\GuidItem.cs" />
<Compile Include="Entities\PublishedEntityBase.cs" />
<Compile Include="Entities\PublishedTenantApartmentState.cs" />
<Compile Include="Entities\PublishedTenantBuildingState.cs" />
<Compile Include="SqlServerDynamicEntityTest.cs" />
<Compile Include="Entities\Author.cs" />
<Compile Include="Entities\Book.cs" />
Expand Down
Expand Up @@ -2,6 +2,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenNETCF.ORM.Tests;
using System.Linq;
using OpenNETCF.ORM.SqlServer.Integration.Test.Entities;

namespace OpenNETCF.ORM.SqlServer.Integration.Test
{
Expand All @@ -11,11 +12,11 @@ public class SqlServerDataStoreTests
private SqlConnectionInfo GetInfo()
{
var connection = new SqlConnectionInfo();
connection.DatabaseName = "EnRouteDev";
connection.ServerName = "enroutemobile.database.windows.net";
connection.DatabaseName = "TEST";
connection.ServerName = "TEST.opennetcf.com";
connection.ServerPort = 1433;
connection.UserName = "EnRouteAPI";
connection.Password = "EnRoute123456!";
connection.UserName = "TEST";
connection.Password = "TEST";
return connection;
}

Expand All @@ -35,6 +36,29 @@ private SqlServerDataStore GetTestStore()
return store;
}

[TestMethod]
public void BaseClassTest()
{
var connection = new SqlConnectionInfo();
connection.DatabaseName = "TEST";
connection.ServerName = "test.opennetcf.com";
connection.ServerPort = 1433;
connection.UserName = "TEST";
connection.Password = "TEST";

var store = new SqlServerDataStore(connection);

try
{
store.AddType<PublishedTenantBuildingState>();
store.AddType<PublishedTenantApartmentState>();
}
catch (Exception ex)
{
}

}

[TestMethod]
public void GuidPKTest()
{
Expand Down
2 changes: 1 addition & 1 deletion nuspec/opennetcf-orm-sqlserver.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>opennetcf-orm-sqlserver</id>
<version>1.0.17254.0</version>
<version>1.0.18058.0</version>
<title>OpenNETCF ORM for Microsoft SQL Server</title>
<authors>Chris Tacke</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand Down

0 comments on commit 325d3ab

Please sign in to comment.