tags:

views:

1138

answers:

1

I am using SubSonic 2.1 for my web application. It's been working fine until recently I added a table in my SQL Server 2005 database to store user files (such as MS Word, PDF, Jpeg, Gif, Tiff files). The files are stored in a column called ReportFile varbinary(max).

After SubSonic generates the code, I build it, and get this error:

'System.Array' does not contain a definition for 'Columns' and no extension method 'Columns' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)

The offending method:

public MyWebApp.ReportFileCollection ReportFiles()
{
    return newMyWebApp.ReportFileCollection().Where(ReportFile.Columns.ReportID, ReportID).Load();
}

Then, I checked file ReportFile.cs, and do see that Columns are defined as struct:

#region Columns Struct
public struct Columns
{
     public static string ReportFileID = @"ReportFileID";
     public static string FileName = @"FileName";
     public static string ReportID = @"ReportID";
     public static string MimeType = @"MimeType";
     public static string FileSize = @"FileSize";
     public static string FileData = @"FileData";
     public static string UploadDate = @"UploadDate";

}
#endregion

I had thought it may have to do with the varbinary(max) column, so I tested generating code with a Test database which also contains a table with a varbinary(max) column, and it worked perfectly.

Because of this error, I have to comment out this ReportFiles method. Anyone knows about this? It is mysterious to me. Any workaround? Thanks a lot.

A: 

It sounds to me like a naming conflict with one of the namespaces that's already been declared. Perhaps the error your seeing isn't telling you the whole truth. You may need to use regexDictionaryReplace in the web.config to rename the columns to non-conflicting values.

ranomore