Quantcast
Channel: .NET Framework inside SQL Server forum
Viewing all articles
Browse latest Browse all 780

How do I define a CLR data type to be comparable? Or is this currently not possible?

$
0
0

I'm trying to define a CLR data type, in C#, which can be used in either 'SELECT DISTINCT ...' or 'SELECT ... GROUP BY ...'. When I try it, I get one of the errors:

    Msg 421, ...
    The MyType data type cannot be selected as DISTINCT because it is not comparable.

    Msg 249, ...
    The type "MyType" is not comparable. It cannot be used in the GROUP BY clause.

I've tried implementing the IComparable interface on the data type, but it made no difference. Is there actually as way to do this? If there is, I believe it would allow either statement to work.

However, since I know that operator overloading is currently not supported, presumably as it would require much more complex expression analysis and code generation, I wouldn't be surprised if there's no way to do this at present. 






Viewing all articles
Browse latest Browse all 780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>