Archive for June, 2010
Nightly news, 25 June 2010
New Zealand has shut down for the day because of the footie — even our Fearless Leader Mr Trask has taken the day off to watch it. However, his minions soldier on. Here’s this week’s batch of fixes and enhancements.
Silverlight Elements
We’ve added a new MultiCalendar control to Silverlight Elements, which allows you to display multiple months and select multiple dates, either as a range or as multiple dates or ranges.
LightSpeed
We’ve made several improvements around joins this week. You can now use multiple criteria in joins, and in LINQ you can conveniently express this by using an anonymous type as the join argument. We’ve also added some support for querying on through associations.
We’ve also provided a way to resize entities vertically in the designer, for those cases where you have an entity with very few properties but lots of associations. Vertical resizing isn’t turned on by default because it can impair usability, but if you have entities like this then you can read about the secret squirrel trick here.
Finally, we’ve released a number of minor fixes and tweaks:
- Auto through entities weren’t being given the right identity type when creating the database tables in the designer.
- We now allow migrations projects to be in solution folders rather than requiring them to be at the root.
- We’ve fixed an issue where the designer custom template path wasn’t being shown for editing if the .lsmodel file was in a subfolder. We’ve also fixed an issue with missing projects in a solution.
- Fixed support for the Visual Basic LINQ Group … By syntax.
- Some fixes for .Equals support in LINQ expressions.
- We have added partial support for discriminated derived types in assemblies other than the one which defines the base type. This only works in limited situations though — if you’ve got a more complex assembly arrangement then let us know.
- Fix for the designer not ignoring transient properties when creating a new database table.
As always, you can get the latest nightly builds from the My Account page in the store.
WPF Elements gets some cool new controls
Tagged as WPF ElementsNot too long ago we packed our Silverlight Elements control suite with a ton of useful controls. Now WPF developers can feel the love too: six of these fantastic controls are now available in WPF Elements, our suite of essential controls for WPF. These controls are in the nightly builds right now: if you’re already a WPF Elements customer, you can simply download the latest nightly and start using the new controls today!
Here’s a tour of what’s new. For more details, you can see the Silverlight Elements announcement or the Silverlight Elements product site. We’ll be updating the WPF Elements site and documentation when we roll these into a formal release.
Dual Slider
The DualSlider has all the main features of a standard WPF Slider, and also provides an additional slider thumb. This makes it useful for selecting the start and end values of some kind of numerical range. You can display the control horizontally or vertically, and constrain the slider values and the range between them. Tick marks can be displayed above or/and below the slider track, the spacing between the tick marks can be changed, and you can also specify whether or not the slider thumbs should snap to the tick marks.
Dual Progress Bar
The built-in WPF ProgressBar control provides a way to show the progress of an operation, but what if you also want to show the progress of individual sub-operations within that larger operation? That’s where the DualProgressBar comes in, providing a means to show a second progress bar within the main one. Even if you don’t need to show sub-operations, you can still use this control as an enhanced version of a normal ProgressBar: for example, to display custom content at the start, center and end of the bar.
Split Button
This control combines a button and a menu. It’s useful when you’ve got multiple related commands, but one of the commands is a common default whereas the others are less common and can be tucked away. The SplitButton provides quick access to the common command via the button, but can be dropped down to reveal a menu of further commands.
Outlook Bar
If you’ve used Microsoft Outlook, you’ll be familiar with this attractive and space-efficient way of displaying tabs. The OutlookBar displays its tabs in a stack, which can be used to select what content it should display, but also allows the user to resize the amount of space allocated to the tabs, automatically collapsing tabs if there’s not enough room to show them fully.
Time Picker and Time Span Picker
These two controls are useful for things like diary or scheduling applications. The TimePicker control provides a way for the user to select a time of day, and supports a configurable drop-down list of suggestions. A related control is the TimeSpanPicker, which allows the user to select a duration. TimeSpanPicker displays time spans nicely as a number of minutes, hours, days or weeks as appropriate.
Themes
Needless to say, all of these controls are provided in all of the WPF Elements themes, so you can keep an elegant Expression or Office-style design that’s consistent with the existing Elements controls (and with WPF Themes for WPF’s built-in controls).
See anything you like?
Sounds useful? Grab the free trial of WPF Elements and try out the new controls. Want more? If you’ve got a control you’d like to see us offering, let us know in our forums and we’ll see what we can do!
Many to many associations and composite keys in LightSpeed
In LightSpeed, we model many-to-many relationships using through associations. Each instance of the many-to-many relationship is represented by an instance of a through entity, which usually has little more than references to the two entities it’s relating.
For example, suppose we have employees and projects: an employee can work on many projects, and a project can be worked on by many employees. So we would have a through association between the Employee and Project entities, and a through entity type to support it, typically called something like EmployeeProject. Each EmployeeProject has references to one Employee and one Project. Plus, because an EmployeeProject is an entity, it has an ID.
So far, so good. But a common idiom at the database level is to say, “Well, hang on. An EmployeeProject is uniquely identified by its EmployeeId and ProjectId. Why are we wasting precious bytes on an ID? Why don’t we make EmployeeId and ProjectId a composite primary key?”
Well, the answer to that is, “Because it will make your life harder.” LightSpeed 3 supports composite keys, but they’re not as easy to work with as surrogate keys. And until recently LightSpeed hasn’t been able to use an ID as the key for an association, so it’s required hand-coded workarounds to realise the association. So if you have the option, it’s just easier to use the separate ID column.
But if the through table already exists and uses the composite primary key, then this option may not be available to you. In which case, how do you work with the composite key and the associations that use parts of the composite as their foreign keys?
The answer comes in two parts — the first part is standard LightSpeed composite key handling, and the second is a new mapping feature in LightSpeed 3.1.
1. Defining the Through Entity With a Composite Key
Our through entity is going to have a composite key consisting of the EmployeeId and ProjectId. We’ve previously discussed how to define such a composite key in code. You can also create it in the designer by just dragging the table onto the design surface.
You’ll also need to override the GeneratedId() method to tell LightSpeed how to assign composite key values. This is discussed in the linked article.
You can now set up the one-to-many associations from Employee and Project to the through entity, and the through association between the Employee and Project classes. Here’s how it looks in the designer at this stage.
2. Backing the Associations onto the Composite Key
At this point, we still have a problem with our one-to-many associations. When LightSpeed sees an association called Employee, it also expects to see an EmployeeId property to hold the foreign key value. It expect this so much that the designer automatically creates this property for you. Trouble is, we don’t want that property, because in our case the foreign key value is the EmployeeId part of the composite key.
To tell LightSpeed to back the Employee association onto some other property rather than the automatic EmployeeId property, we use the Key Property Reference setting. Key Property Reference tells LightSpeed to use an existing property as the foreign key store, rather than the automatic property. The important thing for our composite key scenario is that Key Property Reference supports subproperties. So if we put “Id.EmployeeId” as the Key Property Reference, LightSpeed will use the EmployeeId property of the composite Id as the foreign key. Which is exactly what we need.
(To do this in code, apply the ForeignKeyFieldAttribute to the EntityHolder field. The same path applies in both cases.)
We need to do a similar mapping on the EmployeeProject.Project association, setting the Key Property Reference in this case to Id.ProjectId.
And we’re done! Our through entity now supports many-to-many associations between Employees and Projects without the need for an additional surrogate key.
To reiterate, you’ll usually use this technique only with legacy databases that you can’t change. If you have the choice, it’s much easier to have a separate Id column for all of your entities, including through entities. But if you need to work with an existing database that uses foreign keys as primary keys, Key Property Reference and the ForeignKeyField attribute are the way to do it!
Want to know more? Download the free LightSpeed Express edition and try it out!
Nightly news, 18 June 2010
Here it is, all the new hotness from the Mindscape forge…
WPF Elements
We’ve been continuing to enhance WPF Elements with some of the controls from our Silverlight Elements suite. Since the last bulletin we’ve added:
- SplitButton
- DualSlider
- OutlookBar
These controls are available in the current nightly build — check them out!
We’ve also fixed a bug where the IntegerTextBox.ValueChanged event was getting declared incorrectly.
LightSpeed
- The DateTime.Date property is now supported in LINQ queries on SQL Server 2008. (It’s been supported on Oracle and PostgreSQL since 2.2.)
- We’ve made some further tweaks in support of .NET Remoting.
- We’ve made a number of bug fixes around class table inheritance, including some fixes for incorrect joins and aliasing, and an error where the schema wasn’t being respected on derived classes.
Nightly news, 11 June 2010
Lots of stuff going on at Mindscape HQ right now, but we’ve found time to deliver a few enhancements and bug fixes in the last week’s worth of nightly builds. Here’s the goodness.
WPF Elements
We’ve started porting some of the cool controls from Silverlight Elements to WPF, and the following are done and included in the current nightly build of WPF Elements:
- DualProgressBar
- TimePicker
- TimeSpanPicker
Other controls will be arriving in future nightlies — we expect to make a proper announcement next week.
LightSpeed
- We’ve added some checking to the designer to provide a more meaningful warning if you create an association to a concrete table inheritance base class.
- Fixed a problem with validation when using .NET remoting.
- Fixed a designer bug which prevented you from using the tree view to add CLR attributes.
- We’ve fixed a problem in optimistic concurrency checking where version information was being updated on a failed save. This fixes a related issue which could result in concurrency checking being fooled by repeated save attempts.
- Updated SQLite provider to version 1.0.66.
Silverlight Elements
- The RichTextEditor now supports changing the background colour.
WPF Property Grid
- Fixed an issue with dangling event handlers which could cause memory leaks or errors in collection scenarios.
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 24 June 2010 










