Hi! I have a simple object hierarchy:
[HierarchyRoot]
public abstract class AbstractObject : Entity
{
[Field, Key]
public Guid Id { get; private set; }
...
}
public abstract class BlogPost : AbstractObject
{
[Field]
public DateTime? PublishedOn { get; set; }
...
}
public sealed class Article : BlogPost
{
}
Then I am trying to receive 4 latest articles ordered by PublishedDate.
Query<Article>.All.OrderByDescending(a => a.PublishedOn).Take(4)
But instead of it I receive articles ordered by another field. SQL Profiler shows:
SELECT TOP 4 [a].[Id], [a].[TypeId], [a].[CreatedOn], [a].[CreatedBy.Id], [b].[Category.Id], [b].[Title], [b].[PublishedOn], [b].[TeaserImage.Id], [b].[SitePage.Id] FROM (SELECT [c].[Id], [c].[TypeId], [c].[CreatedOn], [c].[CreatedBy.Id] FROM [dbo].[AbstractObject] [c] WHERE ([c].[TypeId] IN (119))) [a] LEFT OUTER JOIN (SELECT [d].[Id], [d].[TypeId], [d].[Category.Id], [d].[Title], [d].[PublishedOn], [d].[TeaserImage.Id], [d].[SitePage.Id] FROM [dbo].[BlogPost] [d] WHERE ([d].[TypeId] IN (119))) [b] ON ([b].[Id] = [a].[Id]) LEFT OUTER JOIN (SELECT [e].[Id], [e].[TypeId] FROM [dbo].[Article] [e]) [f] ON ([f].[Id] = [a].[Id]) ORDER BY [b].[Category.Id] DESC;
Updated at 25.10.2009 18:41:13
Yes, it is very simple. Yesterday I found some problems with LINQ, but most of them were more complex and I found a way to simplify them. This issue was a reason of my registration on your site :)
This thread was imported from our support forum. The original discussion may contain more detailed answer.
Original topic by buck.
asked
Oct 25 '09 at 02:50
Editor
46●156●156●157