I have two tables with same fields one is Nullable and one is not Nullable. I want to check Whether
Ids in Nullable fields exists in table with Non Nullable fields.
I cannot change the Types of these two fields. It is neccessary.
Example:
TableName - MasterUser [UserId int NOT Nullable]
TableName - User [UserId int Nullable]
My Query will be like is like this.
from masteruser in ctx.MasterUser
where GetUserIds(profileId).contains(masteruser.UserId)
select masteruser
List<int> GetUserIds(int profileId)
{
List<int> lstUserIds = (from user in ctx.User
where user.profileId) == profileId)
select user.UserId).ToList();
return lstUserIds;
}
Problem 2:
In the GetUserIds method, Can I make the return type as Nullable int List. If I change List<int> to List<int?> then I am getting error in ToList()
How can I return the Nullabnle int list from this method?
a_anandraj@h...
Member
5 Points
45 Posts
Problem with Quering Nullable and Not Nullable Fields
Jan 29, 2009 11:15 AM|LINK
Hi
I have two tables with same fields one is Nullable and one is not Nullable. I want to check Whether
Ids in Nullable fields exists in table with Non Nullable fields.
I cannot change the Types of these two fields. It is neccessary.
Example:
TableName - MasterUser [UserId int NOT Nullable]
TableName - User [UserId int Nullable]
My Query will be like is like this.
from masteruser in ctx.MasterUser
where GetUserIds(profileId).contains(masteruser.UserId)
select masteruser
List<int> GetUserIds(int profileId)
{
List<int> lstUserIds = (from user in ctx.User
where user.profileId) == profileId)
select user.UserId).ToList();
return lstUserIds;
}
Problem 2:
In the GetUserIds method, Can I make the return type as Nullable int List. If I change List<int> to List<int?> then I am getting error in ToList()
How can I return the Nullabnle int list from this method?
Thanks
Anandraj.A.
LINQ