1

I have type definition of DocumentField_1 & DocumentField_2, which is totally different.

DocumentField_1 has records if assigned value is true otherwise record will not be there, so it is of boolean type. and DocumentField_2 has value with date.

I have following query in sql which I want to write using linq2db.

What is the way to do that having said that those are of different types (boolean & date)?

select 'True' from DocumentField_1 where DocumentField_1.DocumentId = 2
union all
select CONVERT(varchar, value) from DocumentField_2 where DocumentField_2.DocumentId = 2

schema of DocumentField_1 is

Id          -> int
DocumentId  -> int

schema of DocumentField_2 is

Id          -> int
DocumentId  -> int
Value       -> datetime
Anonymous Creator
  • 2,968
  • 7
  • 31
  • 77

1 Answers1

4

If I understand your question correctly, it should be simple:

subquery1.Select(_ => “True”).UnionAll(subquery2.Select(_ => _.Date.ToString());

Instead of ToString(), you can also use Sql.Convert / Sql.Convert2 extensions to customize format