Search code examples
c#web-serviceslinq-to-sql

Build a web service in ASP.NET / C# / Linq-to-SQL


I'm trying to build a simple web service which return a list of shows from a database. The web service has the following code to get its data:

private BLLoptredens BLLoptredens = new BLLoptredens();

[WebMethod]
public Array getVoorstellingenByArtiest(string p_artiest)
{
    return BLLoptredens.selectByArtistName(p_artiest).ToArray() ;
}

The data comes from the BLL, which just passes data from the DAL like so:

public IList<Optreden> selectByArtistName(string p_artiest)
{
   var query = (from o in dc.Optredens
                where o.artiest.Contains(p_artiest)
                select o);
   return query.ToList();
}

This crashes with the following error:

You must implement a default accessor on System.Array because it inherits from ICollection

Can something help me on my way with this?


Solution

  • Is there any particular need to give back an interface instead of a full-fledged generic class?

    Try changingIList<Optreden> to List<Optreden> -- that should do it.