On Wed, 2010-03-10 at 19:17 -0800, Watermelons wrote:
> I have a table called Events and one called Staff and a linking table
> called EventStaff. I create a new EventStaff object and try to assign
> an existing Staff record to it. I get an exception when I hit this
> code:
>
> Edu.EventStaff newEventStaff = new Edu.EventStaff();
> newEventStaff.Staff =(from Edu.Staff staffMember
> in EduDContext.Staff
> where staffMember.ContactID ==
> (int)currentBooking.EduContactID
> select staffMember).Single();
>
> S0133: Implement QueryMethod Queryable.Cast.
Looks like a bug because Queryable.Cast() isn't specially handled, and
the Queryable.Cast() call comes from the cast in your 'where'
expression.
> Where am I going wrong?
Nothing, it's a bug.
As a workaround, remove the cast. If you can't remove the cast, you
might try using an intermediary (I haven't tested this):
Edu.EventStaff newEventStaff = new Edu.EventStaff () {
Staff = (from Edu.Staff staffMember in EduDContext.Staff
let id = (int) currentBooking.EduContactID
where staffMember.ContactID == id
select staffMember).Single(),
};
I don't know if that will work or not. The real fix is (of course) to
fix the bug in DbLinq.
Thanks,
- Jon
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en.