Archive for the ‘LightSpeed’ category
Nightly news, 13 April 2012
LightSpeed
- Added a per-query IncludeFiltered flag to turn off implicit filtering (similar to IncludeDeleted)
- Added core support for SQL Server 2008 hierarchyid type
- Fixed an issue with aliasing when issuing a composed query with paging on SQL Server
- The designer now creates field name constants for special fields
- Fix for implicit filters not being applied in join clauses
WPF Elements
- Data grid star sizing improvements: support for a zero fill weight, new GridLength converter, fix for having to explicitly specify a weight
- Fixed a bug in data grid column virtualisation
- Improved pixel precision of MarkedStripeGrid
- Added Orientation property to MarkedStripeGrid
- Performance improvements for common charting data types
Silverlight Elements
- You can now customise the list of fonts in the HTML editor toolbar
- New properties on ScheduleFormatter for changing the content of most buttons
- We’ve brought over some improvements from WPF Elements to facilitate building multi-schedulers in Silverlight
WPF Diagrams
- Fix for editing node styles in Expression Blend
Web Workbench
- Chirpy compatibility fix
- Fix for Less syntax highlighting when specifying “…” as mixin arguments
- Updated CoffeeScript compiler to 1.3.1
- Added Iced CoffeeScript support
Nightly news, 6 April 2012
By the time you read this, we’ll be off enjoying the long weekend, so consider this a message from the dusty past about that great question of the day: what’s new in this week’s nightly builds.
LightSpeed
- If you’ve got an aggregate in a where clause on a grouping statement, we can now translate that to a HAVING clause on the SQL query
- Fix for an issue where the same association is declared in multiple leaves of a STI hierarchy with different reverse associations
- Clearer error message when a DiscriminatorAttribute has no Attribute value
- Improved support for expressing properties of SQL Server 2008 spatial types in queries. We’ve also made some improvements around SqlDouble to Double conversion.
- Fix for error when several threads raced to be the first to execute the same LINQ query, and the LINQ query involved a closure
- Fixed an issue where a full text search could return an incorrect result if the text search returned a single hit, and that entity was already in the identity map, and there was a QueryExpression filter in addition to the full text search, and the entity in the identity map didn’t conform to the QueryExpression filter. I hope you’re paying attention to this, because there’ll be a quiz later.
- Initial support for generic entity types, which allow you to use the same utility entity type (such as Permission or AuditRecord) in associations with multiple kinds of other entities
- You can now specify a DisconnectedDisplayNamedStrategy on ValidationContext for use on entities which are not part of a unit of work
WPF Elements
- DataGrid automatic column sizing and star sizing
- Support for read-only columns when using a DataTable as the ItemsSource of a DataGrid
- Added DataGrid.HighlightedItem property and associated change event and method
- Added DataGrid.RowHeaderTemplate so you can control the appearance of row ‘headers’ (those little doodads at the left of each row. You know). You can use this for things like row numbering.
- DataGridWrapper now has a property for retrieving the encapsulated DataTable
- Fixed an issue with rendering of the DataGrid frozen column shadow
- We now re-render charts when the Series collection changes
- Added IsSliderVisible option to show sliders on chart axes for panning and zooming. You can also style the sliders using the (wait for it) SliderStyle property.
Web Workbench
- Fix for Less compiler error is the file name or containing folder contained a single quote
NHibernate Designer
- Added ‘formula’ option for entity properties computed in SQL
- Added support for one-way associations
- Added DataMember options for one-to-many associations
You know the drill — free editions from the Downloads page, full editions from the store. Enjoy!
Nightly news, 30 March 2012
Ivan is off moonlighting as a luchador today, so its my turn to provide the weekly update. Its mostly been a week of bug fixes and working toward getting WPF Elements 5.1 out the door with a bunch of performance improvements and new features. Meanwhile we continued to beaver away on all the other products of course :) Here’s what’s new in this week’s nightly builds.
LightSpeed
- Fix for issue with eager loading when we have a STI hierarchy which has multiple branches where the eager load is on a separate branch to the derived type being worked on
- Added support for expressing a HAVING clause within core querying engine, use the Group.Having property to apply this
NHibernate Designer
- Fix for trying to apply a default to MySQL TEXT fields
- Added support for foreign identity generator
WPF Elements
- Fixes relating to NaN axis values on some charting controls
- General performance improvements
Web Workbench
- Added command line compiler tools for paid customers
- Added combining for CoffeeScript
As ever, nightly builds of free editions are available from the downloads page, and of full editions from the store.
Ninja entity filtering in LightSpeed
Tagged as LightSpeed
Sometimes entities come with a ‘natural’ filter — a filter that should be applied by default to all queries, because the database contains stuff that users shouldn’t normally see. The classic example, which is built into the LightSpeed framework, is soft deletion: entities can be kept in the database but marked as logically deleted, and ‘deleted’ entities shouldn’t be returned from queries.
But there are other common use cases for this which aren’t build into LightSpeed, including liveness, currency and security filters. For example:
- In a membership system, you might want queries to consider only active members (liveness).
- In a system where data has a time range during which it is valid, you might want queries to consider only data that are valid at a particular time (currency).
- In a case management system, users should be able to see only cases that they are working on (security).
In LightSpeed 4.0 RTM, you had to be sure to apply these filters to every query, either using your awesome developer brain power (which wouldn’t help when a slack-jawed maintenance programmer took over the code) or by encapsulating queries within a fortress-like repository (which was boring). Even then there were limits to this, for example if an entity which was current or permitted had children some of whom might not be current or permitted.
The current LightSpeed nightly builds offer another approach: interception-based query filters, which allow you to add filter criteria declaratively at the entity level.
Declaring how an entity type should be filtered
To declare that an entity type should be automatically filtered, just apply the new QueryFilterAttribute. QueryFilterAttribute takes a type, which must implement the IQueryFilter interface:
[QueryFilter(typeof(IsActiveFilter))] partial class Member { ... } public class IsActiveFilter : IQueryFilter { ... }
Filtering by interface
But in models where implicit filters make sense, it’s likely that many entities in the model will need similar filters. For example, if several entity types have time ranges during which they’re valid, you’ll probably want to apply the same currency filter to all of them. To support this, LightSpeed allows you to specify QueryFilterAttribute on an interface, and applies the filter to all types that implement that interface. Here’s an example:
[QueryFilter(typeof(IsCurrentFilter))] public interface IValidFromTo { DateTime ValidFrom { get; } DateTime ValidTo { get; } } // Both these entity types inherit IsCurrentFilter from the interface partial class Product : IValidFromTo { ... } partial class Sku : IValidFromTo { ... }
With this idiom the interface becomes a powerful declarative tool for specifying query behaviour, and the query filter implementation can assume the properties in the interface are available for querying on.
Implementing a query filter
Now we know how to specify an implicit filter on an entity, either directly or indirectly through an interface, how do we turn that into an actual query? Here’s the IQueryFilter interface that the query filter type must implement:
public interface IQueryFilter { QueryExpression Filter { get; } }
Let’s implement the IsActiveFilter mentioned in the Member example above. This is just a matter of returning a LightSpeed QueryExpression object that consults the appropriate entity property. A nice simple case is if the database contains an IsActive flag:
public class IsActiveFilter : IQueryFilter { public QueryExpression Filter { get { return Entity.Attribute("IsActive") == true; } } }
If you didn’t explicitly model IsActive, but wanted to implicitly archive all members who hadn’t logged in for, say, 180 days, your filter would look a bit more complex, but it would still be a familiar query expression object:
public class IsActiveFilter : IQueryFilter { public QueryExpression Filter { get { DateTime cutoff = DateTime.UtcNow.AddDays(-180); return Entity.Attribute("LastLogin") < cutoff; } } }
Injecting values into implicit filters
By default, when LightSpeed runs a query on an entity with an implicit filter, it instantiates the IQueryFilter object using its default constructor. This is fine for the IsActive case where there’s nothing to parameterise, but it may be more problematic for the security scenario, where the query filter will depend on the logged-in user. In most cases, this will be available through some global mechanism — in a Web application, for example, the filter could use the HttpContext.Current.User — but sometimes it will be useful to inject data into a filter or otherwise control its behaviour on a per-instance basis.
To do this, you need to use an Interceptor and override the CreateQueryFilter method. This allows you full control over the creation and initialisation of the IQueryFilter object. In practice however we don’t expect this to be widely used so I won’t cover it in detail here — suffice it to say that like most other Interceptor methods we pass in a default callback that you can use to get the default behaviour, but you can choose to bypass this callback and create the IQueryFilter yourself, or post-process the IQueryFilter returned by the callback, or whatever as you see fit.
Turning off filtering
Occasionally you will want to turn off an implicit filter, for example in an admin interface where you want to be able to work with inactive users or have permission to view all cases. To do this, just return null from your IQueryFilter.Filter implementation. You’ll need to implement some way of signalling to your IQueryFilter when it should return null — currently you can do this using a global flag or an interceptor, though we welcome feedback on other use cases.
Try it out!
Implicit entity filtering is available in the current nightly builds of LightSpeed. You can get the free Express Edition from the Downloads page, and the full Professional Edition from the store. Happy coding!
Nightly news, 23 March 2012
Well, it has been a bitterly disappointing week for beard-fondling photos on the Mindscape blog. Kyle is going to have to up his game. On the plus side, this has left us with time to ship a bunch of updates and fixes. Here’s what’s new in this week’s nightly builds.
LightSpeed
- The designer now defaults computed columns (and identity columns if they’re not the ID) to Load Only. This is currently implemented for SQL Server only — let us know if you’d like it for other databases. We also no longer infer validations on computed columns.
- Fixed an error if you used an inheritance-based mocking framework to mock entities with associations
- Fix for error updating database from designer after changing the maximum length of a string property on a concrete table inheritance base class
Silverlight Elements
- New version of the RichTextEditor control. Better. Faster. Swooshier.
WPF Elements
- Data grid performance improvements
- Data grid hierarchical display
- Fixed an issue with using a BindingList as a DataGrid items source
- DataGrid now has a SelectedData property
- Fix for DataGrid keyboard navigation in RowAndCell mode
- DataGrid now has built-in support for user adding rows
Web Workbench
- JavaScript and CSS ‘mash and minify’ support
- Fix for not handling Less escaped (~) literals when they used single instead of double quotes
- Fix for misaligned CoffeeScript comment highlighting if file contained Unix line breaks
- Fixed handling of underscored in unquoted URLs. Unquoted URLs! Forsooth!
- Solution Explorer icons! I can barely wait to see how this looks in Visual
WastelandStudio 11.
As ever, nightly builds of free editions are available from the downloads page, and of full editions from the store.
Categories
BrainDump (1)
Community Code (4)
Events (16)
F# (14)
General (53)
Lab Samples (2)
LightSpeed (268)
MegaPack (8)
News (71)
NHibernate Designer (26)
Nightly news (53)
Phone Elements (24)
Products (87)
Projects (5)
Screencast (6)
SharePoint (3)
Silverlight (14)
Silverlight Elements (66)
SimpleDB Management Tools (20)
Visual Studio (9)
VS File Explorer (7)
Web Workbench (39)
WPF (44)
WPF Diagrams (57)
WPF Elements (110)
WPF Property Grid (32)




Posted by Ivan Towlson on 12 April 2012 



