tags:

views:

20

answers:

1

Hello!

Sorry if this seems a silly questions but can you select from a view in subsonic? I have a view called fixturesinfo and I am running this subsonic query:

  FixturesInfoCollection fixtures = new SubSonic.Select().From<FixturesInfo>()
                .Where(FixturesInfo.Columns.FixtureDate).IsGreaterThan(DateTime.Now.AddMonths(-3))
                .ExecuteAsCollection<FixturesInfoCollection>();

When I run it I get an error dbo.FixturesInfo. This happens with all views. Am I doing something wrong here?

Thanks Bex

+1  A: 

Worked it out.. I am using two database connection string and it appears as it was a generic select it wasn't picking the right one. Instead if I do this:

  FixturesInfoCollection fixtures =new FixturesInfoCollection()
                    .Where(FixturesInfo.Columns.FixtureDate,
                           Comparison.GreaterThan, DateTime.Now)
                           .OrderByAsc(FixturesInfo.Columns.FixtureDate).Load();

It works

Bex
another hint: Always use YourNamespace.DB.Select()... instead of SubSonic().Select()... Every subsonic generated DAL has a DB class that sets up a repository with the right connection for you.
SchlaWiener
Ahh.. thank you..! I am only just starting out with subsonic so not undestanding everything yet.
Bex