Based on the code below, how do I dynamically create a Gake.Orchard.Business.PageContent object in the Gake.Data.Base.DataCollection.Retrieve method?
Below is "working" code; however, I don't think I should be explicitly passing in "typeof(typePageContent)", in order to get it to work. I believe I should be able to get that from "typDataObject". The syntax that I'd like to use, is commented out; however, the line "typDataObject typObj = new typDataObject();" created Gake.Orchard.Data.PageContent, when I need it to create Gake.Orchard.Business.PageContent.
public
partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
PageContentCollection pcc = new PageContentCollection(2,this.GetType().Name); //...}
}
namespace
Gake.Orchard.Business{
public class PageContentCollection : Gake.Orchard.Data.PageContentCollection<PageContent>{
//...
}
}
namespace
Gake.Orchard.Data{
public abstract class PageContentCollection{
public PageContentCollection(int Panel, string Page){
//DataResult result = base.Retrieve("Panel = @1 and Page = @2", Panel, Page); DataResult result = base.Retrieve(typeof(typPageContent), "Panel = @1 and Page = @2", Panel, Page);//...
}
}
}
namespace
Gake.Data.Base{
public abstract class DataCollection{
//public DataResult Retrieve(string Conditions, params object[] Values) public DataResult Retrieve(Type TypeOfChild, string Conditions, params object[] Values){
//...
//typDataObject typObj = new typDataObject();
Object objChild = Activator.CreateInstance(TypeOfChild); //...}
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.