This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Consider the following:
Notice how many times the type for registration is specified. Is there perhaps a chance that we can have a generic Query like this:
And have an overload of Find, FindOne and supporting methods looking similar to this:
Then the usage looks as follows:
The benefit is that the type is validated (and if ReSharper screws up my references, I'll know), and I only have to specify the type once. The problem I have is that every now and then the wrong "type" is passed as the type parameter and introduces bugs. Thanks, Werner |
|
|
I only use the Query functions when I don't know the type ahead of time. I constantly burn myself with LINQ (through a combination of personal incompetence and lots of sharp corners in Lightspeed) but:
... is my friend. Also note you can use Data.Registration.ConfirmationCodeField instead of "ConfirmationCode" in recent builds for additional compile time checking. |
|
|
I don't use LINQ for reasons of reuse as I use generics and interfaces a lot. LINQ and interfaces do not play well. This is why I originally requested the feature to inject queries based on interfaces, so I can reduce the complexity of the system. This request is to make it easier to work with generics within LightSpeed and the query was an over simplified example. Werner |
|
|
LINQ and interfaces play great so long as your interface is IQueryable. :) Playing off LINQ (say, for adding custom sort) led me down a quick path of Lightspeed bugs, LINQ inconsistencies, and an inability to predict which parts of a query would execute in the database or on the server. And not even the wizards at StackOverflow have come up with a way to parameterize multiple orderby columns yet. In contrast, I find the Query interface predictable if a bit verbose. And yeah, there are already generics on things like Query.Join so why not. |
|
|
This is how many of my entities look like:
I find writing LINQ queries that rely on properties on the interface caused problems for LightSpeed (and EF). |
|
|
The
and specifies the type only once. You only need to specify the type in the Query object if you are calling a method that does not specify the entity type itself, e.g. |
|
|
Excellent. I didn't know that. |
|