CapableObjects forum



View model enhancement suggestions

Posted By David Fowler 2011-08-23 17:01:38
Add to Favorites0
Author Message
David Fowler
 Posted 2011-08-23 17:01:38
Supreme Being

Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)

Group: Forum Members
Last Active: 2011-12-22 18:31:00
Posts: 34, Visits: 620
210
I have been looking at code generated view models and have found them potentially useful, but they are missing some features which mean they are no use to me in my projects.

The ability to use specify PS expressions on columns.
The ability to use code-derived expressions on columns.
A simple way to use struct types in view model columns. (see thread http://www.capableobjects.com/apps/InstantForum414/Topic6209-4-1.aspx I never got a satisfactory answer to that one)

Are any of these features planned for the future?
HansKarlsen
 Posted 2011-09-05 11:11:43
Supreme Being

Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)

Group: Administrators
Last Active: Yesterday @ 18:25:39
Posts: 446, Visits: 2 654
David Fowler (2011-08-23)
I have been looking at code generated view models and have found them potentially useful, but they are missing some features which mean they are no use to me in my projects.

#1 The ability to use specify PS expressions on columns.
#2 The ability to use code-derived expressions on columns.
#3 A simple way to use struct types in view model columns. (see thread http://www.capableobjects.com/apps/InstantForum414/Topic6209-4-1.aspx I never got a satisfactory answer to that one)

Are any of these features planned for the future?

#1

Nah- this requirement pops up from time to time - having PS-derived values. The thing is that no one can come up with a generic idea on when to invalidate them - so they will be stale and old real quick.

How we usually handle this is by modeling like this:
ACodeDerivedAssociationThatDoesAPSFetch
ADerivedAttributeThatCanTriggerTheInvalidationOfTheAbove (with set and get)

Then the ACodeDerivedAssociationThatDoesAPSFetch can subscribe to the ADerivedAttributeThatCanTriggerTheInvalidationOfTheAbove and I can set a new value in the ADerivedAttributeThatCanTriggerTheInvalidationOfTheAbove and after that read ACodeDerivedAssociationThatDoesAPSFetch and trust that it will be refetched.

Consider this case:
AllEmployeesThatDid40HoursLastWeek -> Employee
AllEmployeesThatDid40HoursLastWeekFreshnessTimeBigGrinateTime

First time I read AllEmployeesThatDid40HoursLastWeek it is fetched and also set the AllEmployeesThatDid40HoursLastWeekFreshnessTime to Now. I can then read AllEmployeesThatDid40HoursLastWeek multiple times and it is the cached value.

Then I can set the AllEmployeesThatDid40HoursLastWeekFreshnessTime to Now (or whatever as long as I change it) and the next time I read AllEmployeesThatDid40HoursLastWeek it will be refetched...

#2

I suggest that you code derive in your Model and use those Attributes in the ViewModel. On the otherhand I think we will make the Code generated ViewModel "partial" so that you can have your own code logic in the correct ViewModelClass

#3

To use a struct declared in another assembly:

Go like this:

 <Type CanonicalName="ClassLibrary1.Coord" Type="ClassLibrary1.Coord,

ClassLibrary1, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=5348474bcfb2dae2">
   <CommonName Name="Coord" CaseSensitive="false"/>
   <CommonName Name="ClassLibrary1.Coord" CaseSensitive="false"/>
   <LanguageName Language="C#" Name="ClassLibrary1.Coord"/>
   <LanguageName Language="Delhpi" Name="ClassLibrary1.Coord"/>
   <LanguageName Language="Oxygene" Name="ClassLibrary1.Coord"/>
   <LanguageName Language="VB" Name="ClassLibrary1.Coord"/>
 </Type>


The Canonical name must match the name you use in the model.
When you do this the viewmodel gets generated like so:

   public ClassLibrary1.Coord Coordinate {
     get {
       return
((ClassLibrary1.Coord)(((Eco.ViewModel.Runtime.VMNativeTypeAttribute)(this["
Coordinate"])).Value));
     }
     set {

((Eco.ViewModel.Runtime.VMNativeTypeAttribute)(this["Coordinate"])).Value =
value;
     }
   }

David Fowler
 Posted 2011-09-06 13:23:30
Supreme Being

Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)Supreme Being - (210 reputation)

Group: Forum Members
Last Active: 2011-12-22 18:31:00
Posts: 34, Visits: 620
210
HansKarlsen (2011-09-05)

#2

On the otherhand I think we will make the Code generated ViewModel "partial" so that you can have your own code logic in the correct ViewModelClass


That would be very useful. Any idea when it might be implemented?
RickWeyrauch
 Posted 2011-09-06 17:12:58
Supreme Being

Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)Supreme Being - (1 665 reputation)

Group: Forum Members
Last Active: 2012-04-18 18:57:58
Posts: 249, Visits: 7 773
Ignorant question, but for #1, why not just have it read the DB everytime a PS property is read (don't cache it)? I believe in my PS queries to date, I usually only read the property once, unless some criteria changes, in which case I want it to go to the DB again anyways. But, as I said, that may just be me being ignorant.

Rick Weyrauch
HansKarlsen
 Posted 2011-09-06 19:56:59
Supreme Being

Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)Supreme Being - (3 009 reputation)

Group: Administrators
Last Active: Yesterday @ 18:25:39
Posts: 446, Visits: 2 654
Re-reading the db value each time would be easy but would break how eco treats any other type of value - with as few db-roundtrips as possible.

And then stick that attribute in a UI - there is no telling when it will call the DB... But it probably will not be when you want.


Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top