炫意html5
最早CSS3和HTML5移动技术网站之一

efcore怎么去查询集合的交集?

实体类:

public class data{
public string[] tags{get;set;}
}

OnModelCreating重写:

modelBuilder.Entity<data>().Property(a => a.tags).HasConversion(v => string.Join(',', (v)),
v => string.IsNullOrWhiteSpace(v) ? null : v.Split(',', StringSplitOptions.RemoveEmptyEntries));

筛选查询:

var tgs=new string[]{"test","other"};
var query=DbContext.Set<data>().where(d=>tgs.Intersect(d.tags).Count()>0);

执行后报错:the linq expression could not be translated.

尝试过这样也是报错:

var tgs=new string[]{"test","other"};
var query=DbContext.Set<data>().where(d=>tgs.Intersect(d.tags).ToList().Count>0); 

回答


var like = _articleLikesRepository.Table.ToList().Where(x => x.FromUsersId == userId && x.FromArticlesId == articleId).Count();
if (like < 1)
我查表的时候是这么查的 没查过集合 希望对你有帮助吧

炫意HTML5 » efcore怎么去查询集合的交集?

Java基础教程Android基础教程