Problem with Quering Nullable and Not Nullable Fieldshttp://forums.asp.net/t/1377449.aspx/1?Problem+with+Quering+Nullable+and+Not+Nullable+FieldsThu, 29 Jan 2009 11:15:17 -050013774492900784http://forums.asp.net/p/1377449/2900784.aspx/1?Problem+with+Quering+Nullable+and+Not+Nullable+FieldsProblem with Quering Nullable and Not Nullable Fields <p>Hi</p> <p>I have two tables with same fields one is Nullable and one is not Nullable. I want to check Whether <br> Ids in Nullable fields exists in table with Non Nullable fields.</p> <p>I cannot change the Types of these two fields. It is neccessary.</p> <p>Example: </p> <p>TableName - MasterUser [UserId int NOT Nullable]<br> TableName - User [UserId int Nullable]</p> <p>My Query will be like is like this.</p> <p>from masteruser in ctx.MasterUser<br> where GetUserIds(profileId).contains(masteruser.UserId)<br> select masteruser</p> <p>List&lt;int&gt; GetUserIds(int profileId)<br> {<br> &nbsp; List&lt;int&gt; lstUserIds = (from user in ctx.User<br> &nbsp;&nbsp;&nbsp; where user.profileId) == profileId)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select user.UserId).ToList();<br> return&nbsp; lstUserIds;</p> <p>}</p> <p>Problem 2:<br> In the GetUserIds method, Can I make the return type as Nullable int List. If I change List&lt;int&gt; to List&lt;int?&gt; then I am getting error in ToList() <br> How can I return the Nullabnle int list from this method?</p> <p>Thanks</p> <p>Anandraj.A.</p> 2009-01-29T11:15:17-05:00