我使用linq查询来创建我的集合,它基于它的id是一个guid.I是一个可以关联到一个或多个产品的项目。我需要的是显示所有与该项目和其他数据相关的产品名称,如名称,摘要,日期aswell.My问题在这里是当我尝试使用变量我是我的数组中的GUID它引发错误,Guid不能转换为int.I'm非常确定,我必须将我的Guid数组转换为int数组,但不知道如何实现它。下面是我的代码。将GUID数组转换为int数组
foreach(Guid i in itemid)
{
var vals = from r in datacontext.ItemTable_s where r.itemID == i select r;
ItemTable_s[] tempdata = vals.ToArray<.ItemTable_s>();
Facet[] ftemp= new Facet[tempdata.Length];
ItemImage image = null;
string s1="";
for (int iv = 0; iv < tempdata.Length; iv++)
{
s1 += tempdata[i].productname + "\n";
}
ftemp[3] = new facet("Productname",facettype.text,s1);
collection.AddItem(tempdata[i].ItemName, null, null,
new ItemImage(new Uri(-tempdata[i].location))
);
}
在我上面的代码中的TempData [i]是从哪里获得错误味精说GUID不能被转换成int implicitly.How修正这个问题还有没有其他更好的办法?
请告诉我一个面,什么是构造函数的参数。 我认为Facet类的3参数是一个整数而不是一个GUID更符合逻辑 –
您可以将Guid转换为整数,但它非常难看。 http://stackoverflow.com/questions/4518684/convert-guid-to-int – rboarman
我的变量我是一个GUID按照我的foreach循环。我的facet都是字符串,但我的tempdata是我的项目guid的数组。 – newuser1555