元素列表错误后的非法字符和缺失

时间:2015-10-23 08:41:05

标签: c# .net razor servicestack

我正在使用Servicestack将自定义对象列表发送到Razor View页面,但我收到Illegal Character and missing ] after element list错误。这就是我从Servicestack Service发送的方式..

var objSet = new List<Setup>()
{
   new Setup { Id = 1, Code = "73878", Name = "Systems", ContactName = "XYZ", ContactEmail = "info@systems.com", IsActive = true },
   new Setup { Id = 1, Code = "99878", Name = "Microsoft Systems",  ContactName= "Archit",ContactEmail = "enquiry@systems.com" ,IsActive = true }
};

return objSet ;

这就是我在Razor View Page中使用的方式..

var dataSet = [@{
    foreach(var row in Model)
    {
        <text>[@row.Code,@row.Name,@row.ContactName,@row.ContactEmail]</text>
    }
}];

请帮我解决这个问题。谢谢..

1 个答案:

答案 0 :(得分:0)

您是否使用属性创建// Database Version private static final int DATABASE_VERSION = 1; // Database Name private static final String DATABASE_NAME = "aa.sqlite"; private static final String DB_PATH_SUFFIX = "/databases/"; static Context ctx; public SqlLiteDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); ctx = context; } public void CopyDataBaseFromAsset() throws IOException { InputStream myInput = ctx.getAssets().open(DATABASE_NAME); // Path to the just created empty db String outFileName = getDatabasePath(); // if the path doesn't exist first, create it File f = new File(ctx.getApplicationInfo().dataDir + DB_PATH_SUFFIX); if (!f.exists()) f.mkdir(); // Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); // transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) > 0) { myOutput.write(buffer, 0, length); } // Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } private static String getDatabasePath() { return ctx.getApplicationInfo().dataDir + DB_PATH_SUFFIX + DATABASE_NAME; } public SQLiteDatabase openDataBase() throws SQLException { File dbFile = ctx.getDatabasePath(DATABASE_NAME); if (!dbFile.exists()) { try { CopyDataBaseFromAsset(); System.out.println("Copying sucess from Assets folder"); } catch (IOException e) { throw new RuntimeException("Error creating source database", e); } } return SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY); } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } 个节点?不应该像

那样
<text>

但我必须承认我不使用Razor,而且我不熟悉您使用的语法...