A. Martial
A. Martial

Reputation: 41

How to create custom table with DAL 2 in Dotnetnuke

I want get a custom table (include columns of 2 tables or more). Below is a "Classes" info.

[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; }
}

This is "Students" info:

[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; }
}

I created a Store procedure to get: Students's infomations and ClassName. how can i do? Thank for reading!

Upvotes: 1

Views: 326

Answers (1)

Chris Hammond
Chris Hammond

Reputation: 8943

I would recommend you look at some sample/existing modules that use DAL2

If you're using DAL2 you don't need to use Stored Procs, with PetaPoco you can use the repo objects to access data.

I would recommend you start your project with my DAL2 module template.

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

That'll get you a great running example, you can swap out your Tables and objects instead of "Item" and "ItemController".

You can also see sample code from a module that has multiple tables/objects in use.

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

Upvotes: 1

Related Questions