使用SubSonic时,您是将数据作为数据集返回还是将其放入强类型自定义集合或通用对象中?
我浏览了亚音速项目,并且在我的数据库中有四个存储过程,它给了我一个带有4个方法的Sps.cs,它们返回一个StoredProcedure对象.
如果您使用了MVC,您是否经常使用StoredProcedure对象或将其包装在业务逻辑周围并返回数据集,列表,集合或其他内容?
数据集仍然是常态还是被其他东西取代?
我想使用SubSonic,因为它说它易于使用并节省时间.
尝试获取MySQL的连接字符串3小时后,我即将放弃它.
Building configuration from C:\Documents and Settings\user\My Documents\Visual Studio 2
008\Projects\ConfigurationItems\ConfigurationItemsMVC\Web.config
Adding connection to MySqlDataProvider
ERROR: Trying to execute generate
Error Message: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
Run Code Online (Sandbox Code Playgroud)
我无法转移它:错误消息:System.ArgumentException:初始化字符串的格式不符合从索引0开始的规范.
我每次尝试运行subsonic.exe/generate都会得到它
这一切都很容易!
这是我的Web.Config
<!-- connectionString="Persist Security Info=False;database=config;server=localhost;user id=config;Password=config" -->
<connectionStrings>
<remove name="ConfigConnectString"/>
<add name="ConfigConnectString" connectionString="Persist Security Info=False;database=config;server=localhost;user id=userid;Password=password" providerName="MySql.Data.MySqlClient"
/>
</connectionStrings>
<SubSonicService defaultProvider="ConfigDatabase">
<providers>
<add type="SubSonic.MySqlDataProvider, SubSonic"
name="MySqlDataProvider"
generatedNamespace="Config"
connectionStringName="ConfigConnectString"
/>
</providers>
</SubSonicService>
Run Code Online (Sandbox Code Playgroud)
我尝试过几件事:
如果我使用SubSonic为我的Web项目创建DAL,我是否需要担心防止SQL注入攻击?
这是一个关于泛型而不是亚音速的问题:
想象一下,如果有以下代码:
List<int> result =
DB.Select(Product.Columns.Id)
.From<Product>()
.ExecuteTypedList<int>();
Run Code Online (Sandbox Code Playgroud)
这很好用,并返回一个包含我的Product表中的ID的通用列表.
但是,如果我想获得ProductName的列表:
List<String> result =
DB.Select(Product.Columns.ProductName)
.From<Product>()
.ExecuteTypedList<String>();
Run Code Online (Sandbox Code Playgroud)
它会抛出编译器消息(翻译自德语):
"string"必须是非抽象类型,其公共构造函数不带参数,以便用作泛型类型或在泛型方法"SubSonic.SqlQuery.ExecuteTypedList()"中用作参数"T".
cause:String没有空的构造函数:
int i = new int; // works
String s = new String; // compiler error: "string" does not contain a constructor that takes '0' argument
Run Code Online (Sandbox Code Playgroud)
如果我使用它,但是有更优雅的方式,我可以使用List<Object>而不是它有效List<String>吗?
更新:List<Object>不起作用.我确实得到了一个对象列表,但这似乎是"空"对象,不包含我的ProductNames(object.ToString()返回{Object})
我已经下载并安装了最新的ASP.Net MVC框架,并安装了Subsonic项目模板.可以理解的是,模板只安装了对MS-SQL服务器的支持,我想知道是否有人创建了.tt模板文件的版本以满足MySql连接的需要?
我已将MySql连接字符串添加到web.config,但在我尝试构建项目时遇到以下特定于MS-SQL的错误 - 所以我假设无法使用默认安装运行MySql.
Error 2 Running transformation: System.ArgumentException: Keyword not supported: 'port'.
at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
at System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value)
at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Microsoft.VisualStudio.TextTemplatingBD967F61E201B022A3F2416D8208F609.GeneratedTextTransformation.GetReader(String sql) in c:\SourceCode\Temp\SubSonic MVC Demo\SubSonic MVC Template1\Models\_SQLServer.tt:line 6
at Microsoft.VisualStudio.TextTemplatingBD967F61E201B022A3F2416D8208F609.GeneratedTextTransformation.LoadTables() in c:\SourceCode\Temp\SubSonic MVC Demo\SubSonic MVC Template1\Models\_SQLServer.tt:line 64
at Microsoft.VisualStudio.TextTemplatingBD967F61E201B022A3F2416D8208F609.GeneratedTextTransformation.TransformText() in c:\SourceCode\Temp\SubSonic MVC …Run Code Online (Sandbox Code Playgroud) 我对使用亚音速或ado.net实体框架非常困惑我应该提供哪一个?我使用asp.net mvc创建一个网站,我需要的是更高的性能,我也想用ORM节省时间.那么我应该使用哪个orm?
当针对具有1400+表的数据库运行模板时,我收到以下错误.服务器显示数百个连接.有没有人知道这是一般的模板生成问题,还是具体使用这些模板.其他较小的DB对我来说也没问题.
正在运行转换:System.InvalidOperationException:超时已过期.从池中获取连接之前经过的超时时间.这可能是因为所有池连接都在使用中并且达到了最大池大小.
在Microsoft.VisualStudio.TextTemplating8D8967BD3E8719BDA6DD9945992440F1的System.Data.SqlClient.SqlConnection.Open()处的System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)处的System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory)处. C:\ POS\POS.Win\Templates\SQLServer.ttinclude中的GeneratedTextTransformation.GetCommand(String sql):c:\ POS\POS.Win\Templates中Microsoft.VisualStudio.TextTemplating8D8967BD3E8719BDA6DD9945992440F1.GeneratedTextTransformation.LoadFKTables(String tableName)中的第13行\ SQLServer.ttinclude:第179行,Microsoft.VisualStudio.TextTemplating8D8967BD3E8719BDA6DD9945992440F1.GeneratedTextTransformation.LoadTables(),位于c:\ POS\POS.Win\Templates\SQLServer.ttinclude:第131行,位于Microsoft.VisualStudio.TextTemplating8D8967BD3E8719BDA6DD9945992440F1.GeneratedTextTransformation.TransformText()in c:\ POS\POS.Win\Templates\ActiveRecord.tt:第21行
我一直在寻找和阅读一个小时,我还没有为SubSonic找到一个很好的教程.你们中有人有推荐吗?
我正在寻找一个快速命令行或winform教程(不是asp.net教程)来接受一个类并创建表,插入一些元素并再次查询它们.我将在稍后进行推进(加入等等或尝试使用linq?).我似乎无法找到任何告诉我查询或插入的命名空间和对象.我确定看到了,var repo=new SimpleRepository(SimpleRepositoryOptions.RunMigrations);但我不确定该怎么做.
我有一个查询,在两个表之间执行UNION.我正在尝试用SubSonic实现同样的功能.我有两个相关的问题:
我是堆栈溢出的新用户,我的英语非常好,我希望你能理解我的麻烦.
当我编译我的模板时,这个档案.cs就可以了(Context,Structs),但在ActiveRecord中代码不完整.
似乎系统Break de compilation在第5017行并没有向我返回任何例外.
我的代码在这里停止:
Run Code Online (Sandbox Code Playgroud)public static PagedList<Veiculoopcional>GetPaged(int pageIndex,int pageSize){return GetRepo().GetPaged(pageIndex,pageSize);
Run Code Online (Sandbox Code Playgroud)} public string KeyName() { return "
我想这可能是我的桌子"VeiculoOpcional"传输或问题的限制..我不知道.
无论如何这是表格的结构:
CREATE TABLE `veiculoopcional` (
`ID_Veiculo` int(11) NOT NULL,
`ID_Opcional` int(4) NOT NULL,
PRIMARY KEY (`ID_Veiculo`,`ID_Opcional`),
KEY `FK_veiculoopcional_Opcional` (`ID_Opcional`),
CONSTRAINT `FK_veiculoopcional_Opcional` FOREIGN KEY (`ID_Opcional`) REFERENCES `opcional` (`ID_Opcional`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_veiculoopcional_Veiculo` FOREIGN KEY (`ID_Veiculo`) REFERENCES `veiculo` (`ID_Veiculo`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过这个问题?我没有在网上找到任何反思
非常感谢.