We are dynamically building some SQL statements and we are utilizing the IN operator. If our value is a collection of values such that:
List<Guid> guids = new List<Guid>()
I want to be able to provider 'guids' to my clause builder, have it verify the type and if it is enumerable create a clause like:
IN ( {Guid1}, {Guid2}, {Guid3} )
Checking that the value is IEnumerable like this:
if (value is IEnumerable)
falls down when a string is passed in (which happens pretty regularly :) ). What is the best way to validate this type of condition?
怎么样:
if(value .GetType().IsGenericType && value is IEnumerable)
您可以尝试将value.GetType().IsGenericType
与您对IEnumerable的检查结合使用。
What about :
value is IEnumerable<Guid>
It's better if you expect Guid instances, isn't it ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.