开发者

SubSonic3 SimpleRepository Relationships Generated are Wrong

I have been told that it's more than likely my database that is setup wrong causing the problems so below are my tables with key fields and queries.

CREATE TABLE Presentations (
    Id INT NOT NULL IDENTITY(1, 1),
    SpeakerId INT NOT NULL,

    CONSTRAINT PK_Presentations PRIMARY KEY (Id),
    CONSTRAINT FK_Presentations_Speaker FOREIGN KEY (SpeakerId) REFERENCES Speakers (Id)
)

CREATE TABLE Speakers (
    Id INT NOT NULL IDENTITY(1, 1),

    CONSTRAINT PK_Speakers PRIMARY KEY (Id)
)

When I execute the following:

presentations = presentations.OrderBy(x => x.Speaker.FirstName);

The query generated looks like:

SELECT  [t0].[Description], [t0].[EventId], [t0].[Id], [t0].[PresentedOn], 
        [t0].[Slug], [t0].[SpeakerId], [t0].[Title], [t0].[Url]
FROM    [Presentations] AS t0
LEFT    OUTER JOIN [Speakers] AS t1 ON (开发者_StackOverflow社区[t1].[Id] = [t0].[Id])
WHERE   ([t1].[FirstName] LIKE 'B' + '%')
ORDER   BY [t1].[FirstName]

The join should be:

LEFT    OUTER JOIN [Speakers] AS t1 ON ([t1].[Id] = [t0].[SpeakerId])

This is an urgent problem, can anyone help?

Related Questions:

  • ASP.NET MVC2 Linq Where Clause using StartsWith
  • Funky Sql Generated using SubSonic Simple Repository, LINQ and ASP.NET MVC

Really appreciate some help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜