LINQ union with BIT column causing Specified cast is not valid error
Tag : chash , By : Eugenio
Date : March 29 2020, 07:55 AM
Hope that helps The generated sql includes the following line, where @p4 corresponds to the Blahblahblah=false line in your projection: DECLARE @p4 Int = 0
var one =
(from ch in TEST_CHARTs
join a in TEST_CHART_SERIES on ch.CHARTID equals a.CHARTID into a_join
from cs in a_join.DefaultIfEmpty()
join ycols in TEST_QUERY_COLS on new { key1 = cs.YAXIS, key2 = ch.QUERYID } equals new { key1 = ycols.COLNAME, key2 = ycols.QUERYID }
where ch.CHARTID == 1
select new
{
ch.CHARTID,
POSITION = 0,
ycols.QUERYID,
ycols.Otherblah,
Blahblahblah = cs.Blahblahblah
}).ToList();
var two =
(from ch in TEST_CHARTs
join xcol in TEST_QUERY_COLS on new { key1 = ch.XAXIS, key2 = ch.QUERYID } equals new { key1 = xcol.COLNAME, key2 = xcol.QUERYID }
where ch.CHARTID == 1
select new
{
ch.CHARTID,
POSITION = 0,
xcol.QUERYID,
xcol.Otherblah
}).ToList();
var three =
from x in two
select new
{
x.CHARTID,
x.POSITION,
x.QUERYID,
x.Otherblah,
Blahblahblah = false
};
var four = one.Union(three).Distinct();
|
Error in LINQ to SQL: specified cast is not valid
Tag : sql , By : ChristianM
Date : March 29 2020, 07:55 AM
should help you out If my memory serves, the Customers table in Northwind does not have CustomerID as int (I think its NVARCHAR). If you wrote the Contact class manually, instead of have LINQ to SQL generate it, make sure that the types on your class match the types in the database table EDIT: From this link http://msdn.microsoft.com/en-us/library/bb399575(v=vs.90).aspx am inclined to think that the CustomerID field is not INT but NVARCHAR (or NCHAR for that matter)
|
LINQ Specified Cast Not Valid
Date : March 29 2020, 07:55 AM
will be helpful for those in need I ended up dropping the table back into my Data Context and everything is working. Obviously something was corrupt with the table that was dropped in there the first time.
|
asp.net - Specified cast not valid Linq
Tag : chash , By : codelurker
Date : March 29 2020, 07:55 AM
hop of those help? If all fields are not null, then cast fields to int instead of nullable int? var projjType = from projT in dtProjList.AsEnumerable()
where projT.Field<int>("ProjectId") == projId &&
projT.Field<int>("FilterId") == 1
select projT;
|
LINQ: Specified Cast is not valid
Tag : linq , By : Arnaud Goudsmit
Date : March 29 2020, 07:55 AM
|