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
|
Hi, I followed the advice here: var query = new Query(typeof(Contribution)); query.Projection.Add("ContributorId"); var results = unitOfWork.Project I changed the "Contribution" to my own entity type, and changed "ContributorId" to "Id". The problem is the results are all 0. (I tried this originally for a datetime and the results were all 01/01/0001) The SQL that executes in my Profiler window is correct, and the results all have the correct values. Please help!! Thanks |
|
|
I'm assuming you're using the We haven't been able to reproduce the behaviour you're seeing. Can you check whether the incorrect behaviour still occurs with the latest nightly build? (I think we used to have an error case projecting into scalars but that was fixed a while back.) If the problem does still occur, can you make us a small project that exhibits the error (just a single entity, a console program that runs the query and prints the results and the SQL script for creating the table) please? Thanks! |
|
|
Thanks Ivan, I have attached a sample project. I was running the last official release of 3.11 but I also tried the last nightly build I had access to, which was ver 3.1.2503.16319. (We will be upgrading to version 4 quite soon). For now, my workaround is to execute custom SQL using an IDbCommand, and loop over the results using an IDataReader. Carl (Using my managers account) |
|
|
Thanks. Your example works for me when I project an int, but I can reproduce your DateTime problem and will look into it. Are you definitely seeing a problem if you change the TheDate projection to an Id projection? Please note that any fix will only be delivered through LightSpeed 4; we will not backport it to 3.11. Also, regarding the workaround, don't forget you can project into a IDataReader without writing custom SQL. Just change your final loop to:
|
|
|
Also, you can use LINQ, which does handle DateTime projections:
|
|
|
Hi Ivan, I tried with the ID column (just an Int32) and it returned 0 and 0, instead of 1 and 2. Code below: List Query query = new Query(typeof(TableTest)); query.Projection.Add("ID"); query.Distinct = true; foreach (int theID in unitOfWork.Project /*SELECT DISTINCT TableTest.Id AS "TableTest.Id" FROM TableTest */ /* 1 2 */ |
|
|
Hmm, thanks. I definitely can't reproduce this one, but looking at the code it seems we did make a fix for primitive types like Int32 but it didn't handle DateTime. So I'm going to pencil this one in as fixed in 4.x; please reopen it if you still see the problem after you migrate to 4.x. The DateTime issue should be fixed in the next nightly build of 4.x. We also had an issue with projecting nullable types which should also be fixed. Again, both of these already work if you use LINQ instead of query objects, and should as far as I know work in 3.11. Do let us know if you still run into problems after upgrading to the 4.x nightly, and thanks for reporting this issue! |
|