ASP.NET MVC - System.Data.DataSet中没有被引用的问题 [英] ASP.NET MVC - System.Data.DataSet not referenced problem
问题描述
嗯,首先对不起,这个问题一定是pretty直线前进的你们,但我挣扎自己就可以了,我需要它的工作的:(
嗯,我在我的应用程序试图牛逼o使用的数据集
Well, first of all sorry about this question it must be pretty straight forward for you guys but I'm struggling myself on it, and I need to make it work :( Well I'm trying t o use DataSet on my application
当我使其我:
The type 'System.Data.DataSet' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data
在我的应用程序System.Data这已经被从C引用:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ System.Data.dll中
in my application System.Data is already being referenced from C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
和我使用我的使用条款,以及
and I'm using on my using clauses as well
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
这DataSet是从web服务的响应
那么如何解决这个问题的任何想法?
This DataSet is a response from a Webservice So any Ideas on how to fix this problem?
PS。我不知道是否有帮助,但我使用nHaml来呈现我的看法
PS. I don't know if it helps, but I'm using nHaml to render my view
非常感谢
更新:
我发现现在唯一的解决方案是不是传递一个DataSet的视图转换器的DataSet到
The only solution I found for now was to instead passing a DataSet to the view converter the DataSet to a
<List<List<String>>
和通过这样整个数据集
List<List<String>> myList = new List<List<String>>();
foreach (DataRow row in dsTrades.Tables[0].Rows)
{
List<String> myListColumns = new List<String>();
for (var index = 0; index < dsTrades.Tables[0].Columns.Count; index ++)
{
myListColumns.Add(row[index].ToString());
}
myList.Add(myListColumns);
}
// THIS SHOULD BE THE DATASET AND NOW
// IT'S CONVERTED TO A LIST WITH STRINGS LIST INSIDE
viewModel.Trades = myList;
return View(viewModel);
其实这完全是疯狂的ins't呢?
Actually this is completely crazy ins't it?
所有这些工作可能若是直接使用DataSet中轻松完成到视图
我希望有人能帮助我用更简单的方式来做到这一点。
All this job could be easily done into the view if using DataSet directly I hope anyone can help me with a more simplistic way to do it
感谢您:)
UPDATE(解决方案)
西蒙的答案是真正有效的,它增加了对System.Data这和System.Xml命名空间之后,但在同一时间工作的第一次尝试, Josh的答案present一个非常好的和冷静的方式与数据集,这在我看来效果要好得多的工作,我想我会去现在。
Simon's answer was really effective and it worked on the first try after adding namespaces for System.Data and System.Xml but at the same time, Josh's answer present a very nice and cool way to work with DataSets, which on my opinion works much better and I think I'll go for it now.
感谢您的帮助。
推荐答案
尝试在nhaml配置中添加明确提及System.Data这
try adding an explicit reference to System.Data in your nhaml configuration
<?xml version="1.0"?>
<configuration>
...
<configSections>
<section name="nhaml" type="NHaml.Configuration.NHamlConfigurationSection, NHaml"/>
</configSections>
...
<nhaml autoRecompile="true">
<assemblies>
<clear/>
...
<add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
<namespaces>
<clear/>
...
<add namespace="System.Data"/>
</namespaces>
</nhaml>
显然与其他文献和更换...配置
obviously replacing "..." with your other references and config
这篇关于ASP.NET MVC - System.Data.DataSet中没有被引用的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!