Thanks for your help!
2 I see "ProjectID" set as the parentIdColumn parameter for the new ObjectTypeInfo instance, is that what I should set to null?
1 Sure, here is the generated class, I had changed the name of the table after I initially posted the question:
using System;
using System.Data;
using System.Runtime.Serialization;
using System.Collections.Generic;
using CMS;
using CMS.DataEngine;
using CMS.Helpers;
using MINE;
[assembly: RegisterObjectType(typeof(ProjectRelatedProjectInfo), ProjectRelatedProjectInfo.OBJECT_TYPE)]
namespace MINE
{
/// <summary>
/// ProjectRelatedProjectInfo data container class.
/// </summary>
[Serializable]
public class ProjectRelatedProjectInfo : AbstractInfo<ProjectRelatedProjectInfo>
{
#region "Type information"
/// <summary>
/// Object type
/// </summary>
public const string OBJECT_TYPE = "MINE.projectrelatedproject";
/// <summary>
/// Type information.
/// </summary>
#warning "You will need to configure the type info."
public static ObjectTypeInfo TYPEINFO = new ObjectTypeInfo(typeof(ProjectRelatedProjectInfoProvider), OBJECT_TYPE, "MINE.ProjectRelatedProject", "ProjectID", null, null, null, null, null, null, "ProjectID", "MINE.project")
{
ModuleName = "MINE",
TouchCacheDependencies = true,
DependsOn = new List<ObjectDependency>()
{
new ObjectDependency("RelatedProjectID", "MINE.project", ObjectDependencyEnum.Binding),
},
};
#endregion
#region "Properties"
/// <summary>
/// Project ID
/// </summary>
[DatabaseField]
public virtual int ProjectID
{
get
{
return ValidationHelper.GetInteger(GetValue("ProjectID"), 0);
}
set
{
SetValue("ProjectID", value);
}
}
/// <summary>
/// Related project ID
/// </summary>
[DatabaseField]
public virtual int RelatedProjectID
{
get
{
return ValidationHelper.GetInteger(GetValue("RelatedProjectID"), 0);
}
set
{
SetValue("RelatedProjectID", value);
}
}
#endregion
#region "Type based properties and methods"
/// <summary>
/// Deletes the object using appropriate provider.
/// </summary>
protected override void DeleteObject()
{
ProjectRelatedProjectInfoProvider.DeleteProjectRelatedProjectInfo(this);
}
/// <summary>
/// Updates the object using appropriate provider.
/// </summary>
protected override void SetObject()
{
ProjectRelatedProjectInfoProvider.SetProjectRelatedProjectInfo(this);
}
#endregion
#region "Constructors"
/// <summary>
/// Constructor for de-serialization.
/// </summary>
/// <param name="info">Serialization info</param>
/// <param name="context">Streaming context</param>
public ProjectRelatedProjectInfo(SerializationInfo info, StreamingContext context)
: base(info, context, TYPEINFO)
{
}
/// <summary>
/// Constructor - Creates an empty ProjectRelatedProjectInfo object.
/// </summary>
public ProjectRelatedProjectInfo()
: base(TYPEINFO)
{
}
/// <summary>
/// Constructor - Creates a new ProjectRelatedProjectInfo object from the given DataRow.
/// </summary>
/// <param name="dr">DataRow with the object data</param>
public ProjectRelatedProjectInfo(DataRow dr)
: base(TYPEINFO, dr)
{
}
#endregion
}
}
And here is the generated Provider class, note the use of multiple "projectId" parameters in most methods:
using System;
using System.Linq;
using CMS.DataEngine;
namespace MINE
{
/// <summary>
/// Class providing ProjectRelatedProjectInfo management.
/// </summary>
public class ProjectRelatedProjectInfoProvider : AbstractInfoProvider<ProjectRelatedProjectInfo, ProjectRelatedProjectInfoProvider>
{
#region "Public methods"
/// <summary>
/// Returns all ProjectRelatedProjectInfo bindings.
/// </summary>
public static ObjectQuery<ProjectRelatedProjectInfo> GetProjectRelatedProjects()
{
return ProviderObject.GetObjectQuery();
}
/// <summary>
/// Returns ProjectRelatedProjectInfo binding structure.
/// </summary>
/// <param name="projectId">MINE Project ID</param>
/// <param name="projectId">MINE Project ID</param>
public static ProjectRelatedProjectInfo GetProjectRelatedProjectInfo(int projectId, int projectId)
{
return ProviderObject.GetProjectRelatedProjectInfoInternal(projectId, projectId);
}
/// <summary>
/// Sets specified ProjectRelatedProjectInfo.
/// </summary>
/// <param name="infoObj">ProjectRelatedProjectInfo to set</param>
public static void SetProjectRelatedProjectInfo(ProjectRelatedProjectInfo infoObj)
{
ProviderObject.SetProjectRelatedProjectInfoInternal(infoObj);
}
/// <summary>
/// Deletes specified ProjectRelatedProjectInfo binding.
/// </summary>
/// <param name="infoObj">ProjectRelatedProjectInfo object</param>
public static void DeleteProjectRelatedProjectInfo(ProjectRelatedProjectInfo infoObj)
{
ProviderObject.DeleteProjectRelatedProjectInfoInternal(infoObj);
}
/// <summary>
/// Deletes ProjectRelatedProjectInfo binding.
/// </summary>
/// <param name="projectId">MINE Project ID</param>
/// <param name="projectId">MINE Project ID</param>
public static void RemoveProjectFromProject(int projectId, int projectId)
{
ProviderObject.RemoveProjectFromProjectInternal(projectId, projectId);
}
/// <summary>
/// Creates ProjectRelatedProjectInfo binding.
/// </summary>
/// <param name="projectId">MINE Project ID</param>
/// <param name="projectId">MINE Project ID</param>
public static void AddProjectToProject(int projectId, int projectId)
{
ProviderObject.AddProjectToProjectInternal(projectId, projectId);
}
#endregion
#region "Internal methods"
/// <summary>
/// Returns the ProjectRelatedProjectInfo structure.
/// Null if binding doesn't exist.
/// </summary>
/// <param name="projectId">MINE Project ID</param>
/// <param name="projectId">MINE Project ID</param>
protected virtual ProjectRelatedProjectInfo GetProjectRelatedProjectInfoInternal(int projectId, int projectId)
{
return GetSingleObject()
.Where("ProjectID", QueryOperator.Equals, projectId)
.Where("RelatedProjectID", QueryOperator.Equals, projectId);
}
/// <summary>
/// Sets specified ProjectRelatedProjectInfo binding.
/// </summary>
/// <param name="infoObj">ProjectRelatedProjectInfo object</param>
protected virtual void SetProjectRelatedProjectInfoInternal(ProjectRelatedProjectInfo infoObj)
{
SetInfo(infoObj);
}
/// <summary>
/// Deletes specified ProjectRelatedProjectInfo.
/// </summary>
/// <param name="infoObj">ProjectRelatedProjectInfo object</param>
protected virtual void DeleteProjectRelatedProjectInfoInternal(ProjectRelatedProjectInfo infoObj)
{
DeleteInfo(infoObj);
}
/// <summary>
/// Deletes ProjectRelatedProjectInfo binding.
/// </summary>
/// <param name="projectId">MINE Project ID</param>
/// <param name="projectId">MINE Project ID</param>
protected virtual void RemoveProjectFromProjectInternal(int projectId, int projectId)
{
var infoObj = GetProjectRelatedProjectInfo(projectId, projectId);
if (infoObj != null)
{
DeleteProjectRelatedProjectInfo(infoObj);
}
}
/// <summary>
/// Creates ProjectRelatedProjectInfo binding.
/// </summary>
/// <param name="projectId">MINE Project ID</param>
/// <param name="projectId">MINE Project ID</param>
protected virtual void AddProjectToProjectInternal(int projectId, int projectId)
{
// Create new binding
var infoObj = new ProjectRelatedProjectInfo();
infoObj.ProjectID = projectId;
infoObj.RelatedProjectID = projectId;
// Save to the database
SetProjectRelatedProjectInfo(infoObj);
}
#endregion
}
}