diff --git a/src/Umbraco.Core/Persistence/Querying/ExpressionHelper.cs b/src/Umbraco.Core/Persistence/Querying/ExpressionHelper.cs index e43a45357a..72e785e8b3 100644 --- a/src/Umbraco.Core/Persistence/Querying/ExpressionHelper.cs +++ b/src/Umbraco.Core/Persistence/Querying/ExpressionHelper.cs @@ -502,10 +502,7 @@ namespace Umbraco.Core.Persistence.Querying protected virtual string GetFieldName(Database.PocoData pocoData, string name) { var column = pocoData.Columns.FirstOrDefault(x => x.Value.PropertyInfo.Name == name); - var fieldName = string.Format("{0}.{1}", - SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(pocoData.TableInfo.TableName), - SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(column.Value.ColumnName)); - return fieldName; + return column.Value.ColumnName; } protected virtual string GetFieldName(string name) @@ -513,9 +510,6 @@ namespace Umbraco.Core.Persistence.Querying if (useFieldName) { - //FieldDefinition fd = modelDef.FieldDefinitions.FirstOrDefault(x => x.Name == name); - //string fn = fd != default(FieldDefinition) ? fd.FieldName : name; - //return OrmLiteConfig.DialectProvider.GetQuotedColumnName(fn); return SyntaxConfig.SqlSyntaxProvider.GetQuotedColumnName(name); } else diff --git a/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs b/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs index 0c14672fac..631efb34b4 100644 --- a/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs +++ b/src/Umbraco.Tests/CodeFirst/CodeFirstTests.cs @@ -2,15 +2,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.IO; -using Umbraco.Core.Models; using Umbraco.Core.ObjectResolution; using Umbraco.Core.Serialization; -using Umbraco.Tests.CodeFirst.Attributes; using Umbraco.Tests.CodeFirst.Definitions; using Umbraco.Tests.CodeFirst.TestModels; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/CodeFirst/Definitions/ContentTypeDefinitionFactory.cs b/src/Umbraco.Tests/CodeFirst/Definitions/ContentTypeDefinitionFactory.cs index 743fca8002..cdeff7ce62 100644 --- a/src/Umbraco.Tests/CodeFirst/Definitions/ContentTypeDefinitionFactory.cs +++ b/src/Umbraco.Tests/CodeFirst/Definitions/ContentTypeDefinitionFactory.cs @@ -32,7 +32,7 @@ namespace Umbraco.Tests.CodeFirst.Definitions var contentTypeAlias = contentTypeAttribute == null ? modelType.Name.ToUmbracoAlias() : contentTypeAttribute.Alias; //Check if ContentType already exists by looking it up by Alias. var existing = ServiceFactory.ContentTypeService.GetContentType(contentTypeAlias); - + Lazy contentType = contentTypeAttribute == null ? PlainPocoConvention(modelType, existing) : ContentTypeConvention(contentTypeAttribute, modelType, existing); diff --git a/src/Umbraco.Tests/CodeFirst/Mvc/UmbracoTemplatePage`T.cs b/src/Umbraco.Tests/CodeFirst/Mvc/UmbracoTemplatePage`T.cs new file mode 100644 index 0000000000..0d38a825f2 --- /dev/null +++ b/src/Umbraco.Tests/CodeFirst/Mvc/UmbracoTemplatePage`T.cs @@ -0,0 +1,23 @@ +using Umbraco.Web.Mvc; + +namespace Umbraco.Tests.CodeFirst.Mvc +{ + public abstract class UmbracoTemplatePage : UmbracoTemplatePage where T : class + { + protected override void InitializePage() + { + base.InitializePage(); + + //set the model to the current node if it is not set, this is generally not the case + if (Model != null) + { + //Map CurrentContent here + } + } + + /// + /// Returns the a strongly typed model + /// + public T CurrentContent { get; private set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Tests/CodeFirst/TestModels/DecoratedModelPage.cs b/src/Umbraco.Tests/CodeFirst/TestModels/DecoratedModelPage.cs index cdf808fb2b..c3e85835e6 100644 --- a/src/Umbraco.Tests/CodeFirst/TestModels/DecoratedModelPage.cs +++ b/src/Umbraco.Tests/CodeFirst/TestModels/DecoratedModelPage.cs @@ -10,20 +10,16 @@ namespace Umbraco.Tests.CodeFirst.TestModels public class DecoratedModelPage { [PropertyType(typeof(TextFieldDataType), PropertyGroup = "Content")] - [SortOrder(0)] public string Author { get; set; } [PropertyType(typeof(TextFieldDataType), PropertyGroup = "Content")] - [SortOrder(1)] public string Title { get; set; } [Richtext(PropertyGroup = "Content")] - [SortOrder(2)] [Description("Richtext field to enter the main content of the page")] public string BodyContent { get; set; } - [SortOrder(3)] [Alias("publishedDate", Name = "Publish Date")] - public DateTime PublishDate { get; set; } + public DateTime PublishDate { get; set; } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/CodeFirst/TestModels/PlainPocoType.cs b/src/Umbraco.Tests/CodeFirst/TestModels/PlainPocoType.cs index cb55fb2db2..27591a522d 100644 --- a/src/Umbraco.Tests/CodeFirst/TestModels/PlainPocoType.cs +++ b/src/Umbraco.Tests/CodeFirst/TestModels/PlainPocoType.cs @@ -2,6 +2,7 @@ namespace Umbraco.Tests.CodeFirst.TestModels { + //Plain Poco Type - plainPocoType public class PlainPocoType { public string Title { get; set; } diff --git a/src/Umbraco.Tests/Persistence/Querying/ContentRepositorySqlClausesTest.cs b/src/Umbraco.Tests/Persistence/Querying/ContentRepositorySqlClausesTest.cs index 847584b8a9..f5a7cf11ca 100644 --- a/src/Umbraco.Tests/Persistence/Querying/ContentRepositorySqlClausesTest.cs +++ b/src/Umbraco.Tests/Persistence/Querying/ContentRepositorySqlClausesTest.cs @@ -20,7 +20,7 @@ namespace Umbraco.Tests.Persistence.Querying .InnerJoin("[cmsContentVersion]").On("[cmsDocument].[versionId] = [cmsContentVersion].[VersionId]") .InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]") .InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]") - .Where("[umbracoNode].[nodeObjectType]='c66ba18e-eaf3-4cff-8a22-41b16d66a972'"); + .Where("nodeObjectType='c66ba18e-eaf3-4cff-8a22-41b16d66a972'"); var sql = new Sql(); sql.Select("*") @@ -49,8 +49,8 @@ namespace Umbraco.Tests.Persistence.Querying .InnerJoin("[cmsContentVersion]").On("[cmsDocument].[versionId] = [cmsContentVersion].[VersionId]") .InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]") .InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]") - .Where("[umbracoNode].[nodeObjectType]='c66ba18e-eaf3-4cff-8a22-41b16d66a972'") - .Where("[umbracoNode].[id]=1050"); + .Where("nodeObjectType='c66ba18e-eaf3-4cff-8a22-41b16d66a972'") + .Where("id=1050"); var sql = new Sql(); sql.Select("*") @@ -81,9 +81,9 @@ namespace Umbraco.Tests.Persistence.Querying .InnerJoin("[cmsContentVersion]").On("[cmsDocument].[versionId] = [cmsContentVersion].[VersionId]") .InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]") .InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]") - .Where("[umbracoNode].[nodeObjectType]='c66ba18e-eaf3-4cff-8a22-41b16d66a972'") - .Where("[umbracoNode].[id]=1050") - .Where("[cmsContentVersion].[VersionId]='2b543516-a944-4ee6-88c6-8813da7aaa07'") + .Where("nodeObjectType='c66ba18e-eaf3-4cff-8a22-41b16d66a972'") + .Where("id=1050") + .Where("VersionId='2b543516-a944-4ee6-88c6-8813da7aaa07'") .OrderBy("[cmsContentVersion].[VersionDate] DESC"); var sql = new Sql(); diff --git a/src/Umbraco.Tests/Persistence/Querying/ContentTypeRepositorySqlClausesTest.cs b/src/Umbraco.Tests/Persistence/Querying/ContentTypeRepositorySqlClausesTest.cs index 289f9ee107..d9fca798e7 100644 --- a/src/Umbraco.Tests/Persistence/Querying/ContentTypeRepositorySqlClausesTest.cs +++ b/src/Umbraco.Tests/Persistence/Querying/ContentTypeRepositorySqlClausesTest.cs @@ -21,8 +21,8 @@ namespace Umbraco.Tests.Persistence.Querying .On("[cmsContentType].[nodeId] = [cmsDocumentType].[contentTypeNodeId]") .InnerJoin("[umbracoNode]") .On("[cmsContentType].[nodeId] = [umbracoNode].[id]") - .Where("[umbracoNode].[nodeObjectType]='a2cb7800-f571-4787-9638-bc48539a0efb'") - .Where("[cmsDocumentType].[IsDefault]='True'"); + .Where("nodeObjectType='a2cb7800-f571-4787-9638-bc48539a0efb'") + .Where("IsDefault='True'"); var sql = new Sql(); sql.Select("*") @@ -51,9 +51,9 @@ namespace Umbraco.Tests.Persistence.Querying .On("[cmsContentType].[nodeId] = [cmsDocumentType].[contentTypeNodeId]") .InnerJoin("[umbracoNode]") .On("[cmsContentType].[nodeId] = [umbracoNode].[id]") - .Where("[umbracoNode].[nodeObjectType]='a2cb7800-f571-4787-9638-bc48539a0efb'") - .Where("[cmsDocumentType].[IsDefault]='True'") - .Where("[umbracoNode].[id]=1050"); + .Where("nodeObjectType='a2cb7800-f571-4787-9638-bc48539a0efb'") + .Where("IsDefault='True'") + .Where("id=1050"); var sql = new Sql(); sql.Select("*") diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 7c22562bcb..70aa6f9732 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -77,6 +77,7 @@ + @@ -104,6 +105,7 @@ +