Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 162357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:22:35+00:00 2026-05-11T11:22:35+00:00

from i in Db.Items select new VotedItem { ItemId = i.ItemId, Points = (from

  • 0
from i in Db.Items select new VotedItem {     ItemId = i.ItemId,     Points = (from v in Db.Votes               where b.ItemId == v.ItemId               select v.Points).Sum() } 

I got this query, however it fails if no votes are found with exception:

The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type. 

I assume its because sum returns an int and not a nullable int, giving sum a int? as input only give the same error, probably cause sum only workes on ints.

Any good workaround for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:22:36+00:00Added an answer on May 11, 2026 at 11:22 am
    from i in Db.Items select new VotedItem {     ItemId = i.ItemId,     Points = (from v in Db.Votes               where b.ItemId == v.ItemId               select v.Points ?? 0).Sum()  } 

    EDIT – ok what about this… (Shooting again since I don’t know your model…):

    from i in Db.Items select new VotedItem {     ItemId = i.ItemId,     Points = (from v in Db.Votes               where b.ItemId == v.ItemId)               .Sum(v => v.Points)  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to MySQL, and I'm running this query, SELECT item_id,amount FROM db.invoice_line WHERE
This query works: item = db.GqlQuery(SELECT * FROM Item WHERE CSIN = 13)[0] although
var items = from c in contacts select new ListItem { Value = c.ContactId,
I have this LINQ... var n = from a in this.DataContext.News select new {
I have this LINQ query: XNamespace ns = NAMESPACE; var items = (from c
int a ; SqlCommand cmd = new SqlCommand ( Select * From items order
My webpage allows users to select items from a dropdown list and has a
i wrote in file showList.php the following form, which select items from the database
I'm trying to figure out how to exclude items from a select statement from
I want to make a view where I can select multiple items from listview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.