LINQ中的内连接示例

时间:2017-12-04 12:59:02

标签: c# sql wpf

我想在图像控件中显示每个字母的所有照片。对于这封信和照片,我考虑了两个表。现在所有的字母都在datagridview中显示。我想点击datagridview所有ralatedphotos都在图像控件中显示。

我使用以下代码:

  private void Showimage()
    {            
        object item = GrdLater.SelectedItem;
        _id = int.Parse((GrdLater.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text);
        var query =(from u in db.Pictures
                  join uc in db.Letters on u.id equals _id
                 select new
                 {
                    u.Pic
                 });
        var result = query.ToList();
        if(result.Count == 1)
        {
            for (i = 0; i <= result.Count; i++)
            {
                byte [] imagearray = (byte [])result[0].Pic;
                MemoryStream ms = new MemoryStream();
                ms.Write(imagearray,0,imagearray.Length);
                System.Drawing.Image image = System.Drawing.Image.FromStream(ms);
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();

                MemoryStream mss = new MemoryStream();
                image.Save(mss, System.Drawing.Imaging.ImageFormat.Bmp);
                mss.Seek(0,SeekOrigin.Begin);
                bi.StreamSource = ms;
                bi.EndInit();
                image1.Source = bi;
            }
        }

    }

这些代码不显示任何内容并返回Null数量 我不

0 个答案:

没有答案