c# - Why is LINQPAD assuming this variable is a System.Int32 and how can I change its mind? -


i'm trying optimize query plugged linqpad keep getting null reference error, can't assign null value system.int32.. when comment out folderid 1 @ end there, error no longer occurs. why assume folderid system.int32 , how can make int32? instead it's nullable , can run query?

(from groupbundle in groupbundles     join usergroup in usergroups on groupbundle.groupid equals usergroup.groupid     join bundle in bundles on groupbundle.bundleid equals bundle.bundleid     usergroup.userid == 75     orderby bundle.bundlename     select new     {         bundleid = bundle.bundleid,         bundlename = bundle.bundlename,         bundleicon = bundle.bundleicon,         usespecialplayer = (bundle.usespecialplayer != null && bundle.usespecialplayer == true) ? true : false,         height = bundle.puheight,         width = bundle.puwidth,         userid = 75,         companyid = 32,         isfavorite = ((from f in favorites f.favoritetypeid == 1 && f.userid == 75 && f.actionid == bundle.bundleid select f).count() > 0) ? true : false,          //this 1 here         folderid = (from cf in categoryfolders              join folder in folders on cf.folderid equals folder.folderid             folder.companyid == 32 &&             cf.categoryid == bundle.bundleid             select cf.folderid).firstordefault() }).distinct() 

add cast nullable int expression being assigned:

folderid = (int?)(from cf in categoryfolders 

is folderid nullable in database? if not, explains this.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -