473,761 Members | 10,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Linq Query "Error 2 Cannot implicitly convert type"

19 New Member
Ok i am trying to use a Linq query to access a dictionary.

Expand|Select|Wrap|Line Numbers
  1. public static Dictionary<string, Client> Clients = new Dictionary<string, Client>();
Using this Linq query:
Expand|Select|Wrap|Line Numbers
  1. IEnumerable<Staff> loginquery = from staff in Database.Staff where staff.Value.Passcode == txt_password.Text select staff;
but i get the error
Expand|Select|Wrap|Line Numbers
  1. Error    2    Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,Client_Care.Classes.DB_Classes.Staff>>' to 'System.Collections.Generic.IEnumerable<Client_Care.Classes.DB_Classes.Staff>'. An explicit conversion exists (are you missing a cast?)
Thanks for any help.
Dec 19 '08 #1
1 8681
balabaster
797 Recognized Expert Contributor
That's because your LINQ query isn't returning what you think it is. Try changing your LINQ query to

var loginquery = ....

instead.

It will still be safely typed. You will then be able to step through the code and see what the issue is using a watch on loginquery to evaluate its contents ;)

This will be more beneficial to you than me telling you directly what the problem is...
Dec 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2959
by: Amir | last post by:
Hi all, I have a table called PTRANS with few columns (see create script below). I have created a view on top that this table VwTransaction (See below) I can now run this query without a problem: select * from dbo.VwTransaction where
2
20176
by: deko | last post by:
SELECT Nz(Min(),#1/1/1000#) AS NextAppt, Appt_ID FROM tblAppointments WHERE Entity_ID=!! AND ApptDate>=Date() If I do not include Appt_ID, it works fine. But I need the ID so I can join other queries to this one. My guess is this is an elementary error... Thanks in advance.
2
2874
by: Jean | last post by:
Hello everyone, I was having the following problem with a query, and after failing to find a similar solution on these newsgroups I decided to post here. I am quite new to Access, so would appreciate any help/pointers in the right direction. The problem is that I keep getting the error to the likes of "Data types in the criterion expression are incompatible" when the query runs.
8
3377
by: Chul Min Kim | last post by:
Hi, I got a BUS ERROR from one of my company's program. Let me briefly tell our environment. Machine : Sun E3500 (Ultra Sparc II 400Mhz CPU 4EA) OS : Solaris7 Compiler : Sun Workshop 5.0 cc complier I get "BUS ERROR" only when I execute the binary which builds
7
12185
by: Mathew Butler | last post by:
I'm investigating an issue I have when pulling data back from MS access I'm retrieving all rows from a column in a table of 5000 rows - accessing a column of type "memo" ( can be 65353 character long) . I'm pulling the data back using ODBC. Details are: Microsoft Access Driver 4.00.6306.00 Jet 4.0 release level that is currently installed (Msjet40.dll ) "Microsoft Jet Engine Library" 4.0.9025.0 After 291 rows are retreived I am...
1
2894
by: stillh2os | last post by:
Hello. I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code will call. I'm getting Error 2664: cannot convert parameter 1 from CallBack __gc * to CUSTOM_HOOK_CALLBACK_FUNCTION. Here's what I have... In my unmanaged DLL -- Header file: --------------------------------------------------- typedef VOID...
2
9046
by: sfrvn | last post by:
I am embarrassed to say I cannot make this work. Recently upgraded to Access 2003, but do not know if that part of problem (AKA 'syntax change'). Would someone be kind enough to lead me by the hand? Table name: LUtblProvider Table field names: provPKID, name, company, type, phone Table name: tblRef Table field names: refPKID, prov, event, src
1
1873
cori25
by: cori25 | last post by:
Paycode': IIf(="01","Meeting",IIf(="02","Training",IIf(="04","Special Project",IIf(="05","QC",IIf(="06","MDU",IIf(="07","UG",IIf(="08","2nd Man",IIf(="09","Sr Tech Other",IIf(="10-1","Loan Out to Nassau",IIf(="10-2","Loan Out to Suffolk",IIf(="10-3","Loan Out to CTHV",IIf(="10-4","Loan Out to Bronx",IIf(="10-5","Loan Out to Brooklyn",IIf(="10-6","Loan Out to NJ North",IIf(="10-7","Loan Out to NJ...
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.