Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Problem
Message
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
Divers
Thread ID:
01476194
Message ID:
01476235
Vues:
28
>>>>>>>>>I'm trying to retrieve an application from my database. I have a Data Context in my app called AppSecurityDataDataContext. Here's my query:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>{ 
>>>>>>>>>    AppSecurityDataDataContext dc = new AppSecurityDataDataContext();
>>>>>>>>>    var app = from a in dc._Applications
>>>>>>>>>                where a.ApplicationId = ApplicationID
>>>>>>>>>                select a;
>>>>>>>>>
>>>>>>>>>}
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>I'm getting "Could not find an implementation of the query pattern for source type 'System.Data.Linq.Table<AppSecurity._Application>'. 'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?"
>>>>>>>>>
>>>>>>>>>I have the using statement in my class. This other method works:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>public static void AddApplication(Application Application)
>>>>>>>>>{
>>>>>>>>>    _Application app = new _Application
>>>>>>>>>    {
>>>>>>>>>        ApplicationName = Application.ApplicationName
>>>>>>>>>    };
>>>>>>>>>
>>>>>>>>>    _DataContext._Applications.InsertOnSubmit(app);
>>>>>>>>>
>>>>>>>>>    try
>>>>>>>>>    {
>>>>>>>>>        _DataContext.SubmitChanges();
>>>>>>>>>    }
>>>>>>>>>    catch (Exception e)
>>>>>>>>>    { 
>>>>>>>>>    }
>>>>>>>>>}
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>Anyone see what's wrong here?
>>>>>>>>
>>>>>>>>==
>>>>>>>
>>>>>>>umm, huh? What does "==" mean?
>>>>>>Not the same as "=":
where a.ApplicationId = ApplicationID
>>>>>
>>>>>If I remove the Where clause, the comp error still occurs
>>>>
>>>>Then it looks as if it indeed isn't able to reference the System.Linq namespace (Your second example isn't using Linq). Are you sure you have a reference to the System.Core.dll in the project?
>>>
>>>
>>>My bad. I was using System.Data.Linq, not System.Linq. Not it works.
>>>
>>>So that begs the question: What the difference between the two?
>>
>>== means 'equals' - which is what you want.
>>= is the assignment operator - using that wouldn't make sense in this context (no pun intended :-} )
>
>
>No, no, no. I meant the difference between System.Data.Linq and System.Linq.

:-}
The System.Linq namespace is in System.Core.dll and contains classes to support Linq in general (Enumerable, Queryable etc)
The Sysem.Data.Linq namespace (in System.Data.Linq.dll) is concerned with Linq to Sql support (DataContext, EntitySet classes etc)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform