Created
June 9, 2013 08:23
-
-
Save sitereactor/5742799 to your computer and use it in GitHub Desktop.
Example of a POCO that is used internally in Umbraco and decorated with various attributes to enable the creation of a table, columns, keys, constraints and indexes using .CreateTable().
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Umbraco.Core.Persistence; | |
using Umbraco.Core.Persistence.DatabaseAnnotations; | |
namespace Umbraco.Core.Models.Rdbms | |
{ | |
[TableName("umbracoNode")] | |
[PrimaryKey("id")] | |
[ExplicitColumns] | |
internal class NodeDto | |
{ | |
[Column("id")] | |
[PrimaryKeyColumn(Name = "PK_structure", IdentitySeed = 1045)] | |
public int NodeId { get; set; } | |
[Column("trashed")] | |
[Constraint(Default = "0")] | |
public bool Trashed { get; set; } | |
[Column("parentID")] | |
[ForeignKey(typeof(NodeDto))] | |
[IndexAttribute(IndexTypes.NonClustered, Name = "IX_umbracoNodeParentId")] | |
public int ParentId { get; set; } | |
[Column("nodeUser")] | |
[NullSetting(NullSetting = NullSettings.Null)] | |
public int? UserId { get; set; } | |
[Column("level")] | |
public short Level { get; set; } | |
[Column("path")] | |
[Length(150)] | |
public string Path { get; set; } | |
[Column("sortOrder")] | |
public int SortOrder { get; set; } | |
[Column("uniqueID")] | |
[NullSetting(NullSetting = NullSettings.Null)] | |
public Guid? UniqueId { get; set; } | |
[Column("text")] | |
[NullSetting(NullSetting = NullSettings.Null)] | |
public string Text { get; set; } | |
[Column("nodeObjectType")] | |
[NullSetting(NullSetting = NullSettings.Null)] | |
[IndexAttribute(IndexTypes.NonClustered, Name = "IX_umbracoNodeObjectType")] | |
public Guid? NodeObjectType { get; set; } | |
[Column("createDate")] | |
[Constraint(Default = "getdate()")] | |
public DateTime CreateDate { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please provide an example that changes string data to "text" type.