Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Since I want one view to only list activities from today I am creating a new view. But it is not working.
Is it a limitation of MVC or UI o Matic ?
Comment author was deleted
Must say I haven't given that a shot but will give it a try now
It does work mapping 2 pocos to the same table but in the event model there isn't an option to check for the type only the table, so I've made the necessary changes (building now) will also add some docs here on how to use
Ok verison 1.6.2 is out that allows you to do the following, say we have these 2 classes (that map to the same table)
[UIOMatic("TestWithDate", "icon-users", "icon-user", RenderType = UIOMaticRenderType.List, SortColumn = "TheDate", SortOrder = "desc")] [TableName("TestWithDate")] public class TestWithDate : IUIOMaticModel { public TestWithDate() { } [UIOMaticIgnoreField] [PrimaryKeyColumn(AutoIncrement = true)] public int Id { get; set; } [UIOMaticField("Firstname", "Enter your firstname")] public string FirstName { get; set; } [UIOMaticField("Lastname", "Enter your lastname")] public string LastName { get; set; } [UIOMaticField("TheDate", "Select a date")] public DateTime TheDate { get; set; } public IEnumerable<Exception> Validate() { return new List<Exception>(); } }
and
[UIOMatic("TestWithDateLimit", "icon-users", "icon-user", RenderType = UIOMaticRenderType.List, SortColumn = "TheDate", SortOrder = "desc")] [TableName("TestWithDate")] public class TestWithDateLimit : IUIOMaticModel { public TestWithDateLimit() { } [UIOMaticIgnoreField] [PrimaryKeyColumn(AutoIncrement = true)] public int Id { get; set; } [UIOMaticField("Firstname", "Enter your firstname")] public string FirstName { get; set; } [UIOMaticField("Lastname", "Enter your lastname")] public string LastName { get; set; } [UIOMaticField("TheDate", "Select a date")] public DateTime TheDate { get; set; } public IEnumerable<Exception> Validate() { return new List<Exception>(); } }
You can see that both have the same table in the tablename attribute
Now the changes I've made are to the event model so you can do the following
First attach to the event
UIOMatic.Controllers.PetaPocoObjectController.BuildingQuery += PetaPocoObjectController_BuildingQuery1;
then check for the type of object instead of checking for the tablename
private void PetaPocoObjectController_BuildingQuery1(object sender, UIOMatic.QueryEventArgs e) { if (e.CurrentType == typeof(TestWithDateLimit)) { e.Query.Where("TheDate >= @0", DateTime.Now.AddDays(-1)); } }
You'll need to be running the latest version in order to get the CurrentType property on the QueryEventArgs
Let me know if you have further questions.
Cheers, Tim
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Problems mapping two models to same table.
Since I want one view to only list activities from today I am creating a new view. But it is not working.
Is it a limitation of MVC or UI o Matic ?
Comment author was deleted
Must say I haven't given that a shot but will give it a try now
Comment author was deleted
It does work mapping 2 pocos to the same table but in the event model there isn't an option to check for the type only the table, so I've made the necessary changes (building now) will also add some docs here on how to use
Comment author was deleted
Ok verison 1.6.2 is out that allows you to do the following, say we have these 2 classes (that map to the same table)
and
You can see that both have the same table in the tablename attribute
Now the changes I've made are to the event model so you can do the following
First attach to the event
then check for the type of object instead of checking for the tablename
You'll need to be running the latest version in order to get the CurrentType property on the QueryEventArgs
Let me know if you have further questions.
Cheers, Tim
is working on a reply...