Home » Blog

rounded header

Archive for the ‘LightSpeed’ category

How not to join tables in LightSpeed

tag icon Tagged as LightSpeed

We’ve had a couple of customers recently asking about writing joins using LightSpeed query expressions.

Not so fast!

A lot of the time when the SQL part of your brain is thinking “I need to write a join here,” what you’re actually doing is traversing an association. And in a lot of cases, LightSpeed can take care of that for you.

Suppose that you want to filter on a property of an associated entity. For example, you want to get all the Comments where the Contribution on which the comment occurs was posted by a particular User. In pseudo-SQL, that would be something like SELECT * FROM Comment WHERE Comment.Contribution.UserId = n. Of course that isn’t legal SQL, and if you wanted to write the query in real SQL you’d use a join to bring the Contribution table into the query.

But in LightSpeed you don’t have to do that. You can use a dotted path just like a C# or VB property access:

var comments = uow.Find<Comment>(Entity.Attribute("Contribution.UserId") == userId);

It even works for collections too. When you dotted-path through a collection, LightSpeed rewrites this as a query that will pass if any member of the collection matches. Here’s a query that gets all Users who have posted a Contribution with a rating of 4 or higher:

var users = uow.Find<User>(Entity.Attribute("Contributions.Rating") >= 4);

Of course there are some cases where you need to reach for an explicit join, but if all you want is to query on a property of an associated entity, don’t touch that dial — just use LightSpeed association syntax and let us take the strain.

Nightly news, 16 March 2012

WPF Elements

  • Added DataSeries.IsShownInLegend property to allow series to be excluded from the legend
  • If a type is edited in the property grid through a type converter instead of a TypeEditor, the grid now shows subproperties if the type converter derives from ExpandableObjectConverter
  • Added support for IBindingList as a source for the DataGrid
  • Fixed a bug which made it difficult to display the SchedulerDialog when double-clicking an item
  • Added DataGridCellEditModeBehavior to specify how the user can cause a DataGrid cell to enter edit mode using the mouse
  • Added new RowAndCell data grid selection mode
  • Improvements to DataGrid keyboard navigation
  • Typing into a DataGrid cell now automatically puts it into edit mode

LightSpeed

  • If a user is editing an entity which is soft-deletable and uses optimistic concurrency checking, and another user deletes it, and the first user then saves their changes, we now raise an OptimisticConcurrencyException
  • Fix for issue where if you queried on a property of an associated entity and that entity was soft-deleted and you were using a naming strategy to map the soft delete column name, it would give you a null reference exception. Bet you didn’t see that one coming
  • Fixed an issue with JSON.NET serialisation
  • Added support for database-side timestamps

NHibernate Designer

  • Added support for creating through tables in the database when the many-to-many association is of List kind

Web Workbench

  • Added support for specifying ‘co-imported’ files in order to include their variables in completion lists and suppress unwanted wigglies from their variables and mixins (use a specially formatted //* ww-expect "filename" comment)
  • Updated Less compiler to 1.3
  • Added Less, Sass and CoffeeScript file templates for Web Site pseudo-projects
  • Improved support for partials naming convention – if you create a file whose name begins with an underscore, it will now default to not compiling (you can turn it back on using the Web Workbench Settings screen)

Nightly builds of free editions are available from the downloads page, and of full editions from the store. Enjoy!

Super charging your data!

tag icon Tagged as LightSpeed

We all want super fast applications – the faster the better! We provide one of the fastest data access products for .NET developers so it made sense to write an article about achieving great results from an ORM. Rather than being on our blog here it’s been posted over on InfoQ.

Of course, the article is not LightSpeed specific, but LightSpeed may be the only ORM for .NET that supports all of the suggested ways of improving performance:
Roadrunner

  • Lazy loading
  • Named aggregates
  • Batching (for all CRUD queries)
  • 1st level cache
  • 2nd level cache
  • Compiled queries

Enjoy the article, if you have any questions or feedback I’d love to see them in the comments. We know that ORMs don’t mean you need to sacrifice performance – quite the contrary, we think a well tuned ORM should be blazingly fast!

Read the article here on InfoQ

Nightly news, 9 March 2012

LightSpeed

  • Fix for not updating the database with a one-to-one association if the entities involved already had a one-to-many association
  • When dragging a table onto the designer from SQL Server, keep field order the same as the column order in the database
  • Designer now allows comma-separated lists of prefixes in Strip Table Prefix and Strip Column Prefix
  • We now handle composite grouping keys where the anonymous type is nested due to joins in the surrounding expression
  • Fix for not being able to use an EntityHolder at the non-FK end of a custom-resolved association (this enables custom-resolved one-to-one associations but requires you to set the new TreatAsTarget flag at the non-FK end)
  • Fix for a cascade delete error in class table inheritance when using optimistic concurrency checking and the parent type is a non-CTI type and the child type is a derived type
  • Improved the exception message if the database returns NULL from a LINQ aggregate query (such as Sum) but the return type of the query is non-nullable (this is an issue for e.g. Sum queries on SQL Server when no rows match)

WPF Elements

  • The property grid now provides a basic ITypeDescriptorContext to TypeConverter.GetStandardValues in most circumstances.

All these fixes and enhancements are in the latest nightly builds — free editions from the downloads page, full editions from the store.

Nightly news, 2 March 2012

A quick reminder that we’re sponsoring the Codemania conference at the end of the month. Tickets are running low so if you’re in New Zealand snap yours up quick!

LightSpeed

  • You can now install the designer into the VS11 beta. And boy does it look colourful compared to the rest of that dreary thing
  • Fix for KeyTable error with TableAttribute
  • Added support for ScaffoldColumnAttribute to dynamic data
  • Entity.AfterLoad is now called only after eager loads have been put in place
  • Fix for table ordering
  • Enabled adding reference columns to SQLite in Update Database and migrations
  • Allow RemovalBehaviorAction.NoActionNoCheck on one-way associations

WPF Elements

  • Fixed a positioning bug with rotated axis labels
  • Fixed incorrect handling of the Background property in the vanilla SplitButton style
  • Improved handling of null and Double.NaN values in a line chart
  • Added a ChartAxis.RangeChanged event
  • Data point labels no longer get displayed if the data points are not in the viewport
  • Fixed an issue with building a ChartAxis in code
  • Fixed an issue with displaying minor tick marks
  • Fixed a visual glitch in Coverflow when reflections were turned off

Web Workbench

  • Fix for Format Document not being applied in @media blocks
  • Added support for specifying properties directly on a Sass namespace
  • Intellisense completion lists now include variables from imported files
  • You can now set up a Compass path to get rid of spurious ‘unknown mixin’ and ‘file not found’ squigglies on Compass imports
  • Fixed an issue where dependencies of a partial with an underscore prefix were not rebuilt if they imported the partial without the underscore
  • Fix for ‘bad file descriptor’ error with Sass @warn directive
  • We will now always create a .min.x file if minification is turned on, so that you don’t get the .min file removed from the project just because of an interim compilation error
  • Fix for the CoffeeScript minifier using the local decimal separator instead of invariant

Internal Systems

  • Scrubs no longer get no love from JD

Nightly builds of free editions are available from the downloads page, full editions from the store.

Data Products Visual Controls Community Store
LightSpeed ORM
NHibernate Designer
SimpleDB Tools
SharePoint Tools
WPF Elements
WPF Diagrams
Silverlight Elements
Forums
Blog
Register
Login
Subscribe to newsletter
Buy Now
My Account
Volume Discounts
Purchase Orders
Contact Us