【问题标题】:How to create custom table with DAL 2 in Dotnetnuke如何在 Dotnetnuke 中使用 DAL 2 创建自定义表
【发布时间】:2017-07-25 18:43:21
【问题描述】:

我想要一个自定义表格(包括 2 个或更多表格的列)。 下面是一个“类”信息。

[Serializable, XmlRoot("Classes")]
[TableName("Classes")]
[PrimaryKey("Id")]
public partial class ClassesInfo
{
    public ClassesInfo()  {}
    public ClassesInfo(int id, string image, string className)
    {Id = id;
     Image= image;
     ClassName = className;
    }
    public int Id { get; set; }
    public string Image{ get; set; }
    public string ClassName { get; set; }
}

这是“学生”信息:

[Serializable, XmlRoot("Students")]
[TableName("Students")]
[PrimaryKey("Id")]
public partial class StudentsInfo
{
    public StudentsInfo()  {}
    public StudentsInfo(int id, string studentName, int age)
    {Id = id;
     StudentName = studentName;
     Age= age);
    }
    public int Id { get; set; }
    public string StudentName{ get; set; }
    public int Age{ get; set; }
}

我创建了一个存储过程来获取:学生信息和班级名称。 我能怎么做? 感谢阅读!

【问题讨论】:

    标签: c# database dotnetnuke data-access-layer


    【解决方案1】:

    我建议您查看一些使用 DAL2 的示例/现有模块

    如果您使用的是 DAL2,则不需要使用存储过程,使用 PetaPoco,您可以使用 repo 对象来访问数据。

    我建议您使用我的 DAL2 模块模板开始您的项目。

    https://github.com/ChrisHammond/DNNTemplates/releases

    这将为您提供一个很好的运行示例,您可以替换您的表和对象,而不是“Item”和“ItemController”。

    您还可以查看使用多个表/对象的模块中的示例代码。

    https://github.com/ChrisHammond/dnnCHAT/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 1970-01-01
      • 2011-08-15
      • 1970-01-01
      • 2017-02-21
      • 2018-05-12
      相关资源
      最近更新 更多