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've got some linq which I'm testing against the latest nightly build on LS3.1
from consumermobile in ConsumerMobiles join consumerbatchconsumer in ConsumerBatchConsumers on consumermobile.Id equals consumerbatchconsumer.ConsumerId join consumerbatch in ConsumerBatches on consumerbatchconsumer.ConsumerBatchId equals consumerbatch.Id where consumerbatch.Id == new Guid("9cdba94c-34b1-4c06-b783-c9dee86562ad") select consumermobile this generates good SQL:
exec sp_executesql N'SELECT t0.ConsumerUID AS [t0.ConsumerUID], t0.Active AS [t0.Active], t0.LockVersion AS [t0.LockVersion], t0.Type AS [t0.Type], ConsumerClientConsumerReference.ClientUID AS [ConsumerClientConsumerReference.ClientUID], ConsumerClientConsumerReference.ConsumerReference AS [ConsumerClientConsumerReference.ConsumerReference], ConsumerMobile.ConsumerMobileUID AS [ConsumerMobile.ConsumerMobileUID], ConsumerMobile.MobileNumber AS [ConsumerMobile.MobileNumber], t1.ConsumerBatchConsumerUID AS [t1.ConsumerBatchConsumerUID], t1.ConsumerBatchUID AS [t1.ConsumerBatchUID], t1.ConsumerUID AS [t1.ConsumerUID], t2.ConsumerBatchUID AS [t2.ConsumerBatchUID], t2.Active AS [t2.Active], t2.ClientUID AS [t2.ClientUID], t2.ID AS [t2.ID], t2.LockVersion AS [t2.LockVersion], t2.Name AS [t2.Name], t2.OptInSmsMessage AS [t2.OptInSmsMessage], t2.OptOutSmsMessage AS [t2.OptOutSmsMessage] FROM Consumer t0 INNER JOIN ConsumerBatchConsumer t1 ON t0.ConsumerUID = t1.ConsumerUID INNER JOIN ConsumerBatch t2 ON t1.ConsumerBatchUID = t2.ConsumerBatchUID LEFT OUTER JOIN ConsumerClientConsumerReference ConsumerClientConsumerReference ON t0.ConsumerUID = ConsumerClientConsumerReference.ConsumerUID LEFT OUTER JOIN ConsumerMobile ConsumerMobile ON t0.ConsumerUID = ConsumerMobile.ConsumerUID WHERE (t2.ConsumerBatchUID = @p0 AND t0.Type = @p1)',N'@p0 uniqueidentifier,@p1 int',@p0='9CDBA94C-34B1-4C06-B783-C9DEE86562AD',@p1=1 go However the ConsumerMobile.MobileNumber is now flowing back:
|
|
|
Above should read: However the ConsumerMobile.MobileNumber is not flowing back: |
|
|
Hi Dave, I am guessing there is an inheritance relationship between Consumer->ConsumerMobile? The reason that the data isnt surfacing is that the aliasing being applied to Consumer is t0 but ConsumerMobile is ConsumerMobile. Only t0 fields will be getting picked back up for loading into the entity. Are you able to send through a copy of your model and we can have a look at whats going on with this :)
Jeremy |
|
|
Found a way around the problem by doing a 2 stage set of linq queries.. ie getting the UIDs of all the parents. Then iterating over that collection, then doing another query inside which gets the child object. Not performant, but it works! |
|