Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:28:21+00:00 2026-05-26T16:28:21+00:00

I am getting this error ‘Operator ‘==’ cannot be applied to operands of type

  • 0

I am getting this error ‘Operator ‘==’ cannot be applied to operands of type ‘System.Guid’ and ‘string” in linq to entityframework below code.
in the below code CustomerId is Guid and customerProfileId is string.

var accountQuery = from C in CustomerModel.CustomerProfile
                  where C.CustomerId == customerProfileId // Error here                    
                 select C;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:28:21+00:00Added an answer on May 26, 2026 at 4:28 pm

    You cannot compare a Guid to a string directly. Either convert the string to a Guid or the Guid to a string.

    Converting a Guid to string is as easy as calling .ToString() on the variable, but it’s important to know that there’s more than one way to format the Guid. Either with or without dashes:

    someguid.ToString() will give you something like B06A6881-003B-4183-A8AB-39B51809F196
    someGuid.ToString("N") will return something like B06A6881003B4183A8AB39B51809F196

    If you decide to convert C.CustomerId to a string make sure you know what format customerProfileId is in.

    If it can be either format, you may be better off converting customerProfileId to a guid: new Guid(customerProfileId).

    The downside of this is that the conversion from string to Guid will throw an exception if it’s not formatted correctly. So, if you got the customerProfileId from user input (like a form field or URL) you should validate it first.

    However, if you pull the conversion to Guid outside your query you’ll probably end up with better performance since comparing Guids is probably faster than comparing strings.

    var customerProfileGuid = new Guid(customerProfileId);  
    // wrap in try catch if needed
    
    var accountQuery = from C in CustomerModel.CustomerProfile
                       where C.CustomerId == customerProfileGuid                    
                       select C;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting this error: System.Data.SqlClient.SqlException : The conversion of a datetime2 data type to a
Hey I am getting this error: error: conversion to non-scalar type requested Here are
I'm getting this error The prefix '' cannot be redefined from '' to '
getting this error: C:\CodeBlocks\kool\praks3\vector.h|62|error: passing 'const Vector<2u>' as 'this' argument of 'std::string Vector::toString() [with
I'm getting this error: Cannot use a DependencyObject that belongs to a different thread
Im getting this error: 10-05 19:36:09.904: WARN/System.err(1039): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed Is
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Anyone getting this error when using the new free chart controls MS bought from
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.