the linq expression must be converted to sql. The Convert function is not supported. if using a late enough version .ToString() should work:
Name = item.UserName.ToString()
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
(
from item in _context.Table1
select new SomeModel
{
Name ="A"
}
)
.Union
(
from item in _context.Table2
select new SomeModel
{
Name = Convert.ToString(item.UserName)
}
)
it is not work,and throw out:Unable to translate set operation when matching columns on both sides have different store types.
Why?
the linq expression must be converted to sql. The Convert function is not supported. if using a late enough version .ToString() should work:
Name = item.UserName.ToString()