我不确定这是否正确,但我有一个返回 json 的 Web 服务。现在我想设置一个条件来忽略在单元格出现显示中返回值为 false 的行。大多数代码的作用非常简单,但是具有真假值的单元格是出现在表格照片中的。在 ms sql 数据库中,appearInShowcase 的类型为 ntext。
public List<wsGalleryPhotos> GetGalleryPhotos(int collectionID)
{
photoDataContext dc = new photoDataContext();
List<wsGalleryPhotos> results = new List<wsGalleryPhotos>();
System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.GetCultureInfo("en-US");
foreach (photo photo in dc.photos.Where(s => s.collectionID == collectionID))
{
if(photo.appearInShowcase == "true")
{
results.Add(new wsGalleryPhotos()
{
photoID = photo.photoID,
collectionID = Convert.ToInt32(photo.collectionID),
name = photo.name,
description = photo.description,
filepath = photo.filepath,
thumbnail = photo.thumbnail
});
}
}
return results;
}