TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nave
NA
9.5k
0
The cast to value type 'Int32' failed because the materializ
Oct 17 2013 6:16 AM
I have this code:
var item = (from se in _db.Events
where se.ID == id
select new PseudoEvent()
{
ID = se.ID,
categoryId = se.Categories.ID,
}).FirstOrDefault();
The "Events" and "Categories" tables have a relationship:
"Events" table > Category_ID = "Categories" table > ID
When i dont select a category for the event the "Category_ID" in the "Events" table stays "NULL" and in my code above i get this error:
The cast to value type 'Int32' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type
How can i fix that so the event item will be shown even if the Category_ID column is null?
Please advise
Thanks
Reply
Answers (
2
)
How to insert data from one table
Dropdown menu(i.e SubMenu) not wporking properly in Firefox