Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number Of Rows In Data Context
Message
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01470032
Message ID:
01470054
Views:
29

>>I'd like to create an array of objects:
>>
>>
>>aspnetApplication[] applications = new aspnetApplication[dc.aspnet_Applications.Count}];
>>
>>
>>I get "Cannot convert method group 'Count' to non-delegate type 'int'. 'DC' is the DBML. What's wrong here?
>
>Having to read between the lines a bit here - but if I understand correctly what you're trying to do :
aspnetApplication[] applications = dc.aspnet_Applications.ToArray();
Update: But there's something wrong there. Logically it would be
aspnet_Applications[] applications = dc.aspnet_Applications.ToArray();





Actually, here's the entire service method. I was hoping for a cleaner way to return the apps:
public CentralSecurityResponse<aspnetApplication[]> GetAllApplications()
{
    var response = new CentralSecurityResponse<aspnetApplication[]>();
    try
    {
        using (var dc = new l2sCentralSecurityDataContext())
        {
            List<aspnetApplication> apps = new List<aspnetApplication>();

            foreach (var app in dc.aspnet_Applications)
            {
                aspnetApplication aspnetApp = new aspnetApplication { ApplicationId = app.ApplicationId, 
                                                                        ApplicationName = app.ApplicationName, 
                                                                        ConfigurationId = app.ConfigurationID, 
                                                                        Description = app.Description };


                apps.Add(aspnetApp);
            }

            response.Data = apps.ToArray(); ;
            return response;
        }
    }
    catch (Exception ex)
    {
        LogEvent.Invoke(new LogEventArgs(System.Diagnostics.EventLogEntryType.Error, ex.ToString(), ""));
        response.IsError = true;
        response.Error = ex;
        return response;
    }
}
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform