473,218 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

Linq 2 sql, enum, no supported translation to SQL

Hi, I'm using linq 2 sql, and I specified a custom enum type
(CompanyType) to one of the Company table field.
When I'm querying like this:

IEnumerable<CompanyTypevalidTypes= ...;
var v = from c in db.Companies
where validTypes.Contains(c.CompanyType)
select c;

I got an exception says:

Method 'Boolean Contains(MyNamespace.CompanyType)' has no
supported translation to SQL.

If I use int instead of "MyNamespace.CompanyType" as the type of
property "CompanyType" (and the IEnumerable<intvalidTypes),
everything works. So what should I do to make my custom enum types
work?

Thanks!
Jun 27 '08 #1
1 4017
On Jun 24, 12:23*pm, deerchao <deerc...@gmail.comwrote:
Hi, I'm using linq 2 sql, and I specified a custom enum type
(CompanyType) to one of the Company table field.
When I'm querying like this:

IEnumerable<CompanyTypevalidTypes= ...;
var v = from c in db.Companies
* * where validTypes.Contains(c.CompanyType)
* * select c;

I got an exception says:

* * Method 'Boolean Contains(MyNamespace.CompanyType)' has no
supported translation to SQL.

If I use int instead of "MyNamespace.CompanyType" as the type of
property "CompanyType" (and the IEnumerable<intvalidTypes),
everything works. So what should I do to make my custom enum types
work?

Thanks!
Sorry, it's my fault.
I checked again, the validTypes is not of Type
IEnumerable<CompanyTypebut HashSet<CompanyType>.
Everything works after I change the declared type of validTypes into
IEnumerable.
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rouben Rostamian | last post by:
I searched the C99 standard and clc's FAQ but was unable to find an answer to the following issue. I hope that someone here can illuminate me. Suppose I have: enum myenum { enuma, enumb,...
12
by: Charlie | last post by:
I have a file, data.c, where I define all of my global variables. I then have a header file, data.h, which I include in every file in which I reference all of the variables defined in data.c. ...
8
by: Alcides | last post by:
Hello all, I learn about LINQ here in this forum. I been a VB.NET programmer for quite a while and we are using an internal solution for SQL access. I have some experience with C# and I started...
1
by: shapper | last post by:
Hi, I wonder, is there some tool that transforms SQL procedures to LINQ? :-) I want to use LINQ but I have so much work done in SQL that would be great to transform my SQL code to LINQ. ...
1
by: Steve Gerrard | last post by:
Roshawn wrote: I could be way off, so take this with a grain of salt. I would first remove the (0) after Products; then I would specify a property for myMerchant, i.e. name. That would give...
2
by: shapper | last post by:
Hello, I am using the following Linq Query: var filter = (from t in database.Tags where t.Name.StartsWith(q, StringComparison.CurrentCultureIgnoreCase) orderby t.Name select t);
5
by: Seb | last post by:
I want to count activity in a given month. I'm trying to do so with the linq code below however it reports: Error 1 'a' is inaccessible due to its protection level var ActivityByMonths = from a...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
8
by: benn | last post by:
Here's the setup... Defines.h file contains: enum DAY { monday, tueday }; DayFunctions.h contains prototype: void printIsMonday ( enum DAY currentDay); DayFunctions.c contains:
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.