日期:2014-05-20 浏览次数:20832 次
/// <summary>
/// 图片对象
/// </summary>
public class ImageInfo
{
/// <summary>
/// 图片所属类型:多个类型之间用逗号风格
/// </summary>
public string TypeIds { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
}
public class Test
{
List<ImageInfo> list = new List<ImageInfo>();
public Test()
{
list.Add(new ImageInfo() { Title = "test msage title", TypeIds = "1,2" });
list.Add(new ImageInfo() { Title = "test msage title", TypeIds = "11,2" });
list.Add(new ImageInfo() { Title = "test msage title", TypeIds = "212,5,8,12" });
list.Add(new ImageInfo() { Title = "test msage title", TypeIds = "8,22" });
list.Add(new ImageInfo() { Title = "test msage title", TypeIds = "87,93" });
}
public List<ImageInfo> SelectImageInfos(string typeId)
{
var list = new List<ImageInfo>();
list.Where()//查询typeId=1的数据 结果中不能包含11,21等这样的数据
return list;
}
}
list.Where(o=>(","+o+",").IndexOf(",11,")==-1 && (","+o+",").IndexOf(",21,")==-1)//查询typeId=1的数据 结果中不能包含11,21等这样的数据
list.Where(p => p.TypeIds.Split(',').Any(c => c.Equals("1")));