Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法强制转换类型为';System.Windows.DataObject';输入“;产品「;_C#_Entity Framework_Casting - Fatal编程技术网

C# 无法强制转换类型为';System.Windows.DataObject';输入“;产品「;

C# 无法强制转换类型为';System.Windows.DataObject';输入“;产品「;,c#,entity-framework,casting,C#,Entity Framework,Casting,我厌倦了在DragDrop中将对象转换为Product,Product类型是EntityFrameWork类型请帮助我该怎么做? 我的代码如下所示: void IDroppingTarget.Drop(GAMA.gpf.Utils.DragDrop.IDropInformation dropInfo) { // ... Product t = (Product)dropInfo.Data; // Data is containign the

我厌倦了在DragDrop中将对象转换为Product,Product类型是EntityFrameWork类型请帮助我该怎么做? 我的代码如下所示:

void IDroppingTarget.Drop(GAMA.gpf.Utils.DragDrop.IDropInformation dropInfo)
    {
            // ...
            Product t = (Product)dropInfo.Data; // Data is containign the product that 
                                                // draged from the sourcecollection
            // ...
        }
    }

你不能就这样投。你需要使用新的方法

var dataObject = dropInfo.Data;
if(dataObject.GetDataPresent(typeof(Product)))
{
    Product t = (Product)dataObject.GetData(typeof(Product)); 
}