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,
for(var pos = 0; pos < count; pos += 5000) Regards, Jerremy |
|
|
Hi Jerremy, In regards to #1 - if you could let give us more detail on this that would help us in tracking this down - a repro sample is always very useful for this :) For #2, you should look at using UnitOfWork.Project which returns an IDataReader for handling scenarios where you dont want to have entities hydrated but want to work over the raw data such as your scenario above, but you would need to write some custom mapping code rather than using the .AsDto extension methods.
Jeremy |
|
|
To expand a bit on Jeremy's comments: 1. I think we currently only support enums stored as integers in the database. But as Jeremy says, information about the exception message or a repro case is always useful. 2. In addition to using Project to get an IDataReader, you can use a LINQ Select, but you'll need to explicitly load properties because LINQ can't look inside the AsDto method: query.Select(b => new BlahDto { This will give you a sequence of BlahDto objects which saves you working down at the data reader level -- but internally it is executing a projection rather than loading an entity so it should result in no entities being cached in the UOW. |
|
|
I've included a test project. Test case #0 will succeed, but both test case #1 and test case #2 will fail. Even though test case #1 uses an integer enumerator! As said, this test was run against MSSQL (not sure if it matters). I wanted to use the Select but the enum-bug was getting in my way. Is there any info of the performance difference between a raw IDataReader and a Select into either a Dto or anonymous type? And as far as I know, an IDataReader is a forward-only DataReader. How would this compare to, lets say, this code: foreach(var test in uow.Tests.Select(x => new { x.Whatever }) { } Will the above foreach first get all the data, or act like a IDataReader and retrieve per row? |
|
|
A LINQ Select currently gets all the rows (i.e. it assembles all the results into a list rather than yielding them one at a time as they come off the data reader). (It doesn't get all the columns.) I don't think this need be an issue for you, though, because you are building batches anyway. So you can use the Skip and Take operators to load only the rows required for the current batch. |
|
|
Re your test case, can you provide us with the CREATE TABLE statements for your database please? Thanks! |
|
|
Well I created the table using LightSpeed with the exception of later changing the Id to Identity (forgot that during creation). But the script is this: USE [QuoteExport]
Why on earth did LightSpeed add constraints? Not that it should matter. |
|
|
This is a bug with our handling of enums in a LINQ projection. LINQ projections are materialised in a slightly different way to entities, which is why your case #0 worked but your cases #1 and #2 didn't -- the bug was on the LINQ projection path, not the entity materialisation path. I've committed a fix for this and it will be included in nightly builds dated 13 Mar 2010 and above. Please let us know if you still see problems. Thanks for reporting this issue and for the detailed repro case! |
|