Jonathan Yaniv Ben Avraham Jonathan Yaniv Ben Avraham - 2 years ago 66
SQL Question

Not sure why I'm getting this C# error

The error is:

Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments

I have no idea why this is happening, please bare in mind that I'm very new to C# and don't exactly understand how to work with it yet. I'm trying to get the file to retrieve a column from a database table and insert it into a CSV file with extra headers.
The database table is cmsDictionary and the column is key, this should populate the CSV key column and the others should be blank to be populated by the user which will then be imported into the cmsLanguageText table.

//This is my controller file which is throwing the error.

using UmbracoImportExportPlugin.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Text;
using Umbraco.Core.Persistence;
using Umbraco.Web;
using Umbraco.Web.WebApi;
using System.Data;
using System.Data.SqlClient;

namespace UmbracoImportExportPlugin.App_Code
public class ExportDictionaryAllController : UmbracoAuthorizedApiController

[System.Web.Http.AcceptVerbs("GET", "POST")]
public static void ExportAll(List<Item> DictionaryItems)
getList(List<Item> DictionaryItems);
string attachment = "attachment; filename= DictionaryItems.csv";
HttpContext.Current.Response.AddHeader("Content-Disposition", attachment);
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.AddHeader("Pragma", "public");
foreach (Item item in DictionaryItems)

private static void WriteItemInfo(Item item)
StringBuilder sb = new StringBuilder();
AddComma(item.Key, sb);
AddComma(item.English, sb);
AddComma(item.Hebrew, sb);
AddComma(item.Russian, sb);

private static void AddComma(string value, StringBuilder sb)
sb.Append(value.Replace(',', ' '));
sb.Append(", ");

private static void WriteColumnName()
string columnNames = "Key, English, Hebrew, Russian";

public List<String> getList(List<Item> DictionaryItems)
UmbracoDatabase db = ApplicationContext.DatabaseContext.Database;
var select = new Sql("SELECT key FROM cmsDictionary");
List<Item> DictionaryItems = db.Fetch<Item>(select);
return DictionaryItems;

Answer Source

Well, this line seems wrong:

getList(List<Item> DictionaryItems);

Should be:


The compiler error should give you a line in the code file where the error is.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download