From PetaPoco to NPoco (#1207)
* NPoco - 2.x (builds) * NPoco - v3.1 (does not build) * NPoco - builds * NPoco - configure database factory (tests fail) * Pick fix from 7.4 * NPoco - stock v3.1 - sort-of working * NPoco - fix merge * Fix Newtonsoft.Json in web.Template.Debug.config * NPoco - fix SELECT * * NPoco - fixing repositories * NPoco - fix EntityRepository * NPoco - fix EntityRepository * NPoco - cosmetic * NPoco - use 3.1.0-u001 from github/zpqrtbnk/NPoco * Fixes build, NPoco needed to be referenced in the cms and UmbracoExamine projects * Fixes lots of tests * fixes more tests * NPoco - bugfixing * Bugfix CacheHelper in tests * Bugfix connection mocking in tests * NPoco - inject database in Sql.Select<> * NPoco - discovery retry policy only once * Enable C# 6 for Umbraco.Core * NPoco - introduce UmbracoSql, cleanup * NPoco - more cleanup and fixing * NPoco - fix UserRepository * Optimize InGroupsOf * Implement UmbracoDatabase.FetchByGroups * NPoco - fix Select * NPoco - simplify GetPagedResultsByQuery * Cherry-pick DisableBrowserCacheAttribute fix from 7.4 * Upgrade NPoco to use Sql<TContext> * U4-8257 - cleanup relators * 4-8257 - cleanup more relators * Upgrade NPoco with more OOTB version * fixes a couple tests, changes double check lock to Lazy<T>
This commit is contained in:
committed by
Shannon Deminick
parent
1b8747bd6d
commit
365a01a476
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NPoco;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
@@ -20,17 +21,15 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||
[Test]
|
||||
public void Can_Generate_Delete_SubQuery_Statement()
|
||||
{
|
||||
var sqlSyntax = new SqlCeSyntaxProvider();
|
||||
|
||||
var mediaObjectType = Guid.Parse(Constants.ObjectTypes.Media);
|
||||
var subQuery = new Sql()
|
||||
var subQuery = Sql()
|
||||
.Select("DISTINCT cmsContentXml.nodeId")
|
||||
.From<ContentXmlDto>(sqlSyntax)
|
||||
.InnerJoin<NodeDto>(sqlSyntax)
|
||||
.On<ContentXmlDto, NodeDto>(sqlSyntax, left => left.NodeId, right => right.NodeId)
|
||||
.Where<NodeDto>(sqlSyntax, dto => dto.NodeObjectType == mediaObjectType);
|
||||
.From<ContentXmlDto>()
|
||||
.InnerJoin<NodeDto>()
|
||||
.On<ContentXmlDto, NodeDto>(left => left.NodeId, right => right.NodeId)
|
||||
.Where<NodeDto>(dto => dto.NodeObjectType == mediaObjectType);
|
||||
|
||||
var sqlOutput = sqlSyntax.GetDeleteSubquery("cmsContentXml", "nodeId", subQuery);
|
||||
var sqlOutput = SqlContext.SqlSyntax.GetDeleteSubquery("cmsContentXml", "nodeId", subQuery);
|
||||
|
||||
Assert.AreEqual(@"DELETE FROM [cmsContentXml] WHERE [nodeId] IN (SELECT [nodeId] FROM (SELECT DISTINCT cmsContentXml.nodeId
|
||||
FROM [cmsContentXml]
|
||||
@@ -47,15 +46,13 @@ WHERE (([umbracoNode].[nodeObjectType] = @0))) x)".Replace(Environment.NewLine,
|
||||
[Test]
|
||||
public void Can_Generate_Create_Table_Statement()
|
||||
{
|
||||
var sqlSyntax = new SqlCeSyntaxProvider();
|
||||
|
||||
var type = typeof (NodeDto);
|
||||
var definition = DefinitionFactory.GetTableDefinition(type, sqlSyntax);
|
||||
var definition = DefinitionFactory.GetTableDefinition(type, SqlContext.SqlSyntax);
|
||||
|
||||
string create = sqlSyntax.Format(definition);
|
||||
string primaryKey = sqlSyntax.FormatPrimaryKey(definition);
|
||||
var indexes = sqlSyntax.Format(definition.Indexes);
|
||||
var keys = sqlSyntax.Format(definition.ForeignKeys);
|
||||
string create = SqlContext.SqlSyntax.Format(definition);
|
||||
string primaryKey = SqlContext.SqlSyntax.FormatPrimaryKey(definition);
|
||||
var indexes = SqlContext.SqlSyntax.Format(definition.Indexes);
|
||||
var keys = SqlContext.SqlSyntax.Format(definition.ForeignKeys);
|
||||
|
||||
Console.WriteLine(create);
|
||||
Console.WriteLine(primaryKey);
|
||||
@@ -142,7 +139,6 @@ WHERE (([umbracoNode].[nodeObjectType] = @0))) x)".Replace(Environment.NewLine,
|
||||
TableName = "TheTable",
|
||||
SchemaName = "dbo"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user