score:4

Accepted answer
var mails = from m in entity.mailboxes
            join p in entity.ordinary_user_profile_info on m.from_id equals p.user_id
            select new maillist
            {
                mid = m.m_id,
                mfrom = m.from_id ?? 0,
                mfomname = p.username,
                msubject = m.subject
            };

score:0

var mails = from m in entity.mailboxes
            join p in entity.ordinary_user_profile_info on m.from_id equals p.user_id
            select new maillist
            {
                mid = m.m_id,
                mfrom = (int)m.from_id,  // error occours here
                mfomname = p.username,
                msubject = m.subject
            };

score:5

var mails = from m in entity.mailboxes
            join p in entity.ordinary_user_profile_info on m.from_id equals p.user_id
            select new maillist
            {
                mid = m.m_id,
                **mfrom = m.from_id.hasvalue ? m.from_id.value : 0**
               //this is saying is, since the int is nullable, 
               //if it has a value, take it, or return 0
                mfomname = p.username,
                msubject = m.subject
            };

Related Query

More Query from same tag