.net mjoin example / models
.net mjoin example / models

In the link section in the mjoin manual: https://editor.datatables.net/manual/net/mjoin
the code given is this:
DtResponse response = new Editor(WebApiApplication.Db, "users")
.Model<UserModel>()
.MJoin(new MJoin("permission")
.Link("users.id", "user_permission.user_id")
.Link("permission.id", "user_permission.access_id")
.Model<AccessModel>()
.Order("permission.name")
.Field(new Field("id")
.Options("permission", "id", "name")
)
)
.Process(formData)
.Data();
it appears the model names are UserModel and AccessModel. However, below that code the models given appear to be named differently (StaffModel and PermissionsModel). I am struggling on using mjoin in my .net project and I think I may have my models built incorrectly. Trying to use the posted manual, I am not getting it.
public class StaffModel : EditorModel
{
public class users : EditorModel
{
public string first_name { get; set; }
public string role { get; set; }
}
}
public class PermissionModel : EditorModel
{
public string id { get; set; }
public string name { get; set; }
}
I think it would help to see a sample of what the json would look like in these examples.
This question has an accepted answers - jump to answer
Answers
Hi,
You are right, the manual is slightly different from the example. If you download the Editor .NET package you'll get all of the examples that are available on the Editor site, but written with backends for .NET.
To help, this is the controller the example uses:
This is the model used for the Mjoin:
And the JSON response is the same as in the live PHP example.
Allan
yeah, I guess jumping between the .net manual and php manual is a bit awkward, but you can get the whole picture doing that, including the javascript for the editor.