我一直在使用subcommander来生成我的dal。我正在使用vb.net和sqlexpress以及.net 3.5
我的webconfig看起来像这样
<!-- add subsonic in for dal-->
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" requirePermission="false"/>
</configSections>
<connectionStrings>
<!-- Development connection string -->
<add name="kimconnection" connectionString="Data Source=7NQ384J\SQLExpress;Initial Catalog=kim2;Integrated Security=True;"/>
</connectionStrings>
<!--Add my provider for subsonic to my database-->
<SubSonicService defaultProvider="kimAppProvider">
<providers>
<clear/>
<add name="kimAppProvider" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="kimconnection" generatedNamespace="kimdata"/>
</providers>
</SubSonicService>
<appSettings>
<!--Add my provider for generating my dal / classes-->
<buildProviders>
<add extension=".abp" type="SubSonic.BuildProvider, SubSonic"/>
</buildProviders>
好吧我的问题是,如果我注释掉我的构建提供程序(因为我认为在使用subcommander生成我的类时我没有使用它),我不能在我的aspx代码后面导入kimdata来访问类。
然而,如果我离开这是,(即不要评论出来)然后我在visual studio中调试我的代码我得到200多个错误,错误信息是“语句不能出现在方法体外”
错误似乎表明这是我编译的app_code在调试时,问题是这是c#,我使用vb,我生成的类是vb,默认语言是vb,所以为什么这是c#并且是这是我得到错误的原因?还是有其他原因,我怎么能解决这个问题,因为我的应用程序不会运行,因为有很多错误,
#ExternalChecksum("d:\dscott\windows\Visual Studio 2008\WebSites\KimV2\App_Code\builder.abp","{406ea660-64cf-4c82-b6f0-42d48172a799}","ECAA88F7FA0BF610A5A26CF545DCD3AA")
using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using SubSonic;
using SubSonic.Utilities;
namespace kimdata
{
/// <summary>
/// Strongly-typed collection for the AlertMessage class.
/// </summary>
[Serializable]
public partial class AlertMessageCollection : ActiveList<AlertMessage, AlertMessageCollection>
{
public AlertMessageCollection() {}
/// <summary>
/// Filters an existing collection based on the set criteria. This is an in-memory filter
/// Thanks to developingchris for this!
/// </summary>
/// <returns>AlertMessageCollection</returns>
public AlertMessageCollection Filter()
{
for (int i = this.Count - 1; i > -1; i--)
{
AlertMessage o = this[i];
foreach (SubSonic.Where w in this.wheres)
{
bool remove = false;
System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
if (pi.CanRead)
{
object val = pi.GetValue(o, null);
switch (w.Comparison)
{
case SubSonic.Comparison.Equals:
if (!val.Equals(w.ParameterValue))
{
remove = true;
}
break;
}
}
if (remove)
{
this.Remove(o);
break;
}
}
}
return this;
}
}
/// <summary>
/// This is an ActiveRecord class which wraps the alertMessages table.
/// </summary>
[Serializable]
public partial class AlertMessage : ActiveRecord<AlertMessage>, IActiveRecord
{
#region .ctors and Default Settings
public AlertMessage()
{
SetSQLProps();
InitSetDefaults();
MarkNew();
}
private void InitSetDefaults() { SetDefaults(); }
public AlertMessage(bool useDatabaseDefaults)
{
SetSQLProps();
if(useDatabaseDefaults)
ForceDefaults();
MarkNew();
}
public AlertMessage(object keyID)
{
SetSQLProps();
InitSetDefaults();
LoadByKey(keyID);
}
public AlertMessage(string columnName, object columnValue)
{
SetSQLProps();
InitSetDefaults();
LoadByParam(columnName,columnValue);
}
protected static void SetSQLProps() { GetTableSchema(); }
#endregion
#region Schema and Query Accessor
public static Query CreateQuery() { return new Query(Schema); }
public static TableSchema.Table Schema
{
get
{
if (BaseSchema == null)
SetSQLProps();
return BaseSchema;
}
}
private static void GetTableSchema()
{
if(!IsSchemaInitialized)
{
//Schema declaration
TableSchema.Table schema = new TableSchema.Table("alertMessages", TableType.Table, DataService.GetInstance("kimAppProvider"));
schema.Columns = new TableSchema.TableColumnCollection();
schema.SchemaName = @"dbo";
//columns
TableSchema.TableColumn colvarMessageID = new TableSchema.TableColumn(schema);
colvarMessageID.ColumnName = "messageID";
colvarMessageID.DataType = DbType.Int32;
colvarMessageID.MaxLength = 0;
colvarMessageID.AutoIncrement = true;
colvarMessageID.IsNullable = false;
colvarMessageID.IsPrimaryKey = true;
colvarMessageID.IsForeignKey = false;
colvarMessageID.IsReadOnly = false;
colvarMessageID.DefaultSetting = @"";
colvarMessageID.ForeignKeyTableName = "";
schema.Columns.Add(colvarMessageID);
TableSchema.TableColumn colvarDocumentType = new TableSchema.TableColumn(schema);
colvarDocumentType.ColumnName = "documentType";
colvarDocumentType.DataType = DbType.AnsiString;
colvarDocumentType.MaxLength = 50;
colvarDocumentType.AutoIncrement = false;
colvarDocumentType.IsNullable = false;
colvarDocumentType.IsPrimaryKey = false;
colvarDocumentType.IsForeignKey = false;
colvarDocumentType.IsReadOnly = false;
colvarDocumentType.DefaultSetting = @"";
colvarDocumentType.ForeignKeyTableName = "";
schema.Columns.Add(colvarDocumentType);
TableSchema.TableColumn colvarMessageTitle = new TableSchema.TableColumn(schema);
colvarMessageTitle.ColumnName = "messageTitle";
colvarMessageTitle.DataType = DbType.AnsiString;
colvarMessageTitle.MaxLength = 200;
colvarMessageTitle.AutoIncrement = false;
colvarMessageTitle.IsNullable = false;
colvarMessageTitle.IsPrimaryKey = false;
colvarMessageTitle.IsForeignKey = false;
colvarMessageTitle.IsReadOnly = false;
colvarMessageTitle.DefaultSetting = @"";
colvarMessageTitle.ForeignKeyTableName = "";
schema.Columns.Add(colvarMessageTitle);
TableSchema.TableColumn colvarMsgPublishDate = new TableSchema.TableColumn(schema);
colvarMsgPublishDate.ColumnName = "msgPublishDate";
colvarMsgPublishDate.DataType = DbType.DateTime;
colvarMsgPublishDate.MaxLength = 0;
colvarMsgPublishDate.AutoIncrement = false;
colvarMsgPublishDate.IsNullable = false;
colvarMsgPublishDate.IsPrimaryKey = false;
colvarMsgPublishDate.IsForeignKey = false;
colvarMsgPublishDate.IsReadOnly = false;
colvarMsgPublishDate.DefaultSetting = @"";
colvarMsgPublishDate.ForeignKeyTableName = "";
schema.Columns.Add(colvarMsgPublishDate);
TableSchema.TableColumn colvarXml = new TableSchema.TableColumn(schema);
colvarXml.ColumnName = "xml";
colvarXml.DataType = DbType.String;
colvarXml.MaxLength = 1073741823;
colvarXml.AutoIncrement = false;
colvarXml.IsNullable = false;
colvarXml.IsPrimaryKey = false;
colvarXml.IsForeignKey = false;
colvarXml.IsReadOnly = false;
colvarXml.DefaultSetting = @"";
colvarXml.ForeignKeyTableName = "";
schema.Columns.Add(colvarXml);
TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
colvarCreatedOn.ColumnName = "createdOn";
colvarCreatedOn.DataType = DbType.DateTime;
colvarCreatedOn.MaxLength = 0;
colvarCreatedOn.AutoIncrement = false;
colvarCreatedOn.IsNullable = false;
colvarCreatedOn.IsPrimaryKey = false;
colvarCreatedOn.IsForeignKey = false;
colvarCreatedOn.IsReadOnly = false;
colvarCreatedOn.DefaultSetting = @"";
colvarCreatedOn.ForeignKeyTableName = "";
schema.Columns.Add(colvarCreatedOn);
TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
colvarCreatedBy.ColumnName = "createdBy";
colvarCreatedBy.DataType = DbType.String;
colvarCreatedBy.MaxLength = 50;
colvarCreatedBy.AutoIncrement = false;
colvarCreatedBy.IsNullable = false;
colvarCreatedBy.IsPrimaryKey = false;
colvarCreatedBy.IsForeignKey = false;
colvarCreatedBy.IsReadOnly = false;
colvarCreatedBy.DefaultSetting = @"";
colvarCreatedBy.ForeignKeyTableName = "";
schema.Columns.Add(colvarCreatedBy);
TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
colvarModifiedOn.ColumnName = "modifiedOn";
colvarModifiedOn.DataType = DbType.DateTime;
colvarModifiedOn.MaxLength = 0;
colvarModifiedOn.AutoIncrement = false;
colvarModifiedOn.IsNullable = true;
colvarModifiedOn.IsPrimaryKey = false;
colvarModifiedOn.IsForeignKey = false;
colvarModifiedOn.IsReadOnly = false;
colvarModifiedOn.DefaultSetting = @"";
colvarModifiedOn.ForeignKeyTableName = "";
schema.Columns.Add(colvarModifiedOn);
TableSchema.TableColumn colvarModifiedBy = new TableSchema.TableColumn(schema);
colvarModifiedBy.ColumnName = "modifiedBy";
colvarModifiedBy.DataType = DbType.String;
colvarModifiedBy.MaxLength = 50;
colvarModifiedBy.AutoIncrement = false;
colvarModifiedBy.IsNullable = true;
colvarModifiedBy.IsPrimaryKey = false;
colvarModifiedBy.IsForeignKey = false;
colvarModifiedBy.IsReadOnly = false;
colvarModifiedBy.DefaultSetting = @"";
colvarModifiedBy.ForeignKeyTableName = "";
schema.Columns.Add(colvarModifiedBy);
BaseSchema = schema;
//add this schema to the provider
//so we can query it later
DataService.Providers["kimAppProvider"].AddSchema("alertMessages",schema);
}
}
#endregion
#region Props
PK Collections
#endregion
#region Deep Save
#endregion
}
}
非常感谢任何帮助或建议。
丹
答案 0 :(得分:0)
实际上你必须告诉亚音速用于代码生成的代码语言。
如果使用子命令,则可以在命令行中添加/lang vb
参数。如果您使用构建提供程序,我95%肯定亚音速将选择自己使用的正确语言。您犯的一个可能的错误是,根据文档:http://subsonicproject.com/docs/Setting_up_SubSonic_2.x,buildprovider部分必须位于编译标记内:
<compilation debug="true" defaultLanguage="C#">
<!--########################## SubSonic Build Provider ###############################-->
<!--This will NOT WORK in Medium Trust-->
<buildProviders>
<add extension=".abp" type="SubSonic.BuildProvider, SubSonic"/>
</buildProviders>
您应该使用
为自己创建一个 <compilation debug="true" defaultLanguage="VB">
答案 1 :(得分:0)
大家好,感谢您的回答,不过我以前尝试了所有这些并且无法让它发挥作用,幸运的是我现在已经解决了这个问题。
我是通过创建自己的类vb类库,添加引用system.web,system.configuration,subsonic.dll和相关的dll来实现的,然后我添加了一个带有我的连接字符串和服务提供者的app配置,然后生成了我的然后,我将类构建为dll。
我将DLL包含在我的网站bin文件夹中,现在一切都编译好了。
然而,现在这意味着我必须将我的dal作为kimDal.kimdata引用但是嘿它的工作原理我是
感谢所有
丹