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<Com panyTypevalidTy pes= ...;
var v = from c in db.Companies
where validTypes.Cont ains(c.CompanyT ype)
select c;
I got an exception says:
Method 'Boolean Contains(MyName space.CompanyTy pe)' has no
supported translation to SQL.
If I use int instead of "MyNamespace.Co mpanyType" as the type of
property "CompanyTyp e" (and the IEnumerable<int validTypes),
everything works. So what should I do to make my custom enum types
work?
Thanks! 1 4068
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<Com panyTypevalidTy pes= ...;
var v = from c in db.Companies
* * where validTypes.Cont ains(c.CompanyT ype)
* * select c;
I got an exception says:
* * Method 'Boolean Contains(MyName space.CompanyTy pe)' has no
supported translation to SQL.
If I use int instead of "MyNamespace.Co mpanyType" as the type of
property "CompanyTyp e" (and the IEnumerable<int validTypes),
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<Com panyTypebut HashSet<Company Type>.
Everything works after I change the declared type of validTypes into
IEnumerable. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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, enumc };
near the top of a file, outside any functions.
|
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.
For the most part, I am having no problem with this. However, I
defined an variable of type myenum in data.c:
enum myenum
{
|
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 to write a blog to share my
experiences with a sql framework.
I would like to hear some opinions about LINQ, is it the main thing
when accessing sql now? what are the main advantages/disavantages
using it. Nothing fancy, just drop a few lines...
|
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.
Thanks,
Miguel
|
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
brands = db.Brands.Where( _
Function(b) b.Products.Merchant.name = myMerchant.name _
| |
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);
|
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 in db.ActivityDatas
where a.BeginDateTime >= From && a.BeginDateTime <= To
where a.SubActivityId == sat
group a by a.BeginDateTime.Month into mg
select new { a.BeginDateTime.Month, count = mg.Count() };
|
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
|
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:
|
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...
|
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...
| |
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |