我有一个奇怪的问题,我无法找到解决方案:
我制作了一个用 C# 编写的小 WPF 应用程序,它使用附加的 SQL Server Express .mdf 数据库,然后我通过 LINQ 对其进行操作。
我在表单上有一个 ListView,其中 datacontext 设置为.DataContext = dr.FindAllBuyOrders()
返回 IQueryable BuyOrder 对象。这一切都很好。但是,当我使用 ObjectDataProvider 通过 xaml 执行相同操作时:
<ObjectDataProvider MethodName="FindAllBuyOrders" ObjectType="{x:Type local:DataRepository}" x:Key="dataBuyOrders" />
<ListView Name="listViewBuyOrders" VerticalContentAlignment="Top" ItemsSource="{Binding Source={StaticResource dataBuyOrders}}" ItemTemplate="{StaticResource listViewBuyOrders}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
然后我收到以下错误:
An attempt to attach an auto-named database for file
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Data.mdf
failed. A database with the same name exists, or specified file
cannot be opened, or it is located on UNC share.