查找数组

var items = postDb.CustomerTags
    .Where(m => m.Tags.Contains("近一周线下有消费"))
    .Take(100)
    .ToList();

// 当Tags为List<string> 时 生成语句:
// SELECT c.cardno, c.addtime, c.tags
// FROM customertag AS c
// WHERE TRUE = FALSE
// LIMIT @__p_0

// 当Tags为string[] 时 生成语句:
// SELECT c.cardno, c.addtime, c.tags
// FROM customertag AS c
// WHERE '近一周线下有消费' = ANY(c.tags)
// LIMIT @__p_0
var items = postDb.CustomerTags
    .Where(m => m.Tags.Contains("近一周线下有消费") || m.Tags.Contains("今天线下有消费"))
    .Take(100)
    .ToList();

// SELECT c.cardno, c.addtime, c.tags
// FROM customertag AS c
// WHERE '近一周线下有消费' = ANY(c.tags) OR '今天线下有消费' = ANY(c.tags)
// LIMIT @__p_0



异常

InvalidCastException: Cannot write DateTime with Kind=Local to PostgreSQL type 'timestamp with time zone', only UTC is supported. 
Note that it's not possible to mix DateTimes with different Kinds in an array/range. 
See the Npgsql.EnableLegacyTimestampBehavior AppContext switch to enable legacy behavior.

发现版本:6.0 7.0

解决

在程序启动的位置增加如下代码:

AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);