Model with references to anothers model. ¿It´s possible?
Model with references to anothers model. ¿It´s possible?
Hi!
Is it possible to make a selection in which a model that a reference to another model is selected?
Example:
public class Table1
{
public int Id { get; set; }
public string Name { get; set; }
public Table2 table2 { get; set; }
}
public class Table2
{
public int Id { get; set; }
public string Name { get; set; }
}
When I do the next code, I get "Invalid column name table2"
var response = new Editor(db, dbName, dbPKey)
.Model<Table1>("Table1")
.Model<Table2>("Table2")
.Field(new Field("Table1.table2")
.Options(new Options()
.Table("Table2")
.Value("Id")
.Label("Name "))
.Validator(Validation.DbValues(new ValidationOpts { Empty = false }))
)
.LeftJoin("Table1", "Table1.table2", "=", "Table2.Id")
.TryCatch(false)
.Process(Request)
.Data();
Answers
Hi,
No I'm afraid not - as the documentation notes:
You'd need to drop
public Table2 table2 { get; set; }
from your Table1 class.Allan