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
|
Using lightspeed 4 or 5 in linqpad through SQL SERVER 2008: I created a query with projections on it and then proceed to call the UnitOfWork.Count(query) method. What I am seeing is that it is running the query as it would using UnitOfWork.Project except it tried to parse the first row and column's data as a long. Obviously this is not desired behaviour since the first column was a string and that is not COUNT. Am I doing something wrong? I expect that it should wrap the query in a COUNT and return a long result with the number of rows and not a long-parsed first column/row. If I go to the LightSpeed changelog it says
I understand that as it is saying it should work how I expect it to. Is this an issue? A misunderstanding of how I should count using projections? |
|
|
This refers to behaviour for the LINQ provider - e.g. if you perform a LINQ query like:
UnitOfWork.Count is not compatible with projection based query unless the projection returns a scalar value which can be cast to a long (which will then be returned as the result) although clearly we are not doing a good enough job at surfacing a useful error to alert you to this. To handle this using the normal querying API you will want to wrap your projection with another query which you are going to count over, e.g.
|
|
|
Ahhh, that makes much more sense now :P Another question while I'm here then. When I do this inner query pattern to count, it seems to add an Id column from type "MyEntity" but I already had a projection from a joined table as a column named Id. Is there a way to specify a column alias so that a projection doesn't conflict? The message I get is:
I saw there is an overload for the Projection.Add() method but it lets you specify the table alias and not the column alias if I understand correctly. Is this possible? I am letting it choose the joins based on the relationships in the lightspeed model and not specifying them manually if that has any effect. |
|
|
Yes thats correct regarding the way the overload works. You cant alias the columns, thats controlled by LightSpeed itself and shouldn't be required. If you are getting Id specified multiple times then that would seem to indicate that an invalid statement is being produced. You can confirm this by enabling logging (see: http://www.mindscapehq.com/documentation/lightspeed/Testing-and-Debugging/Logging) and reviewing the statement that is being generated - if we are producing an invalid statement then if you can fire us through a repro project for this then we would be keen to look at getting it fixed :)
|
|
|
Hi, have plans to do this just not enough time at the moment Is it ok if it's a linqpad script? |
|
|
Yep thats fine as long as you also include your model and any data needed to help repro the problem.
|
|