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 8082427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:05:39+00:00 2026-06-05T17:05:39+00:00

I have the following SQL snippet within a select statement: CASE WHEN wot.id LIKE

  • 0

I have the following SQL snippet within a select statement:

CASE 
WHEN wot.id LIKE '%Correct%' THEN 'Corrective'
WHEN wot.id LIKE '%Pred%' THEN 'Preventative'
ELSE 'OTHER'
END
AS worktype

which I have translated into LINQ to SQL like this:

WorkType = groupItem.Key.Id.Contains("Correct") ? "Corrective" : "OTHER" || 
WorkType = groupItem.Key.Id.Contains("Pred") ? "Preventative" : "OTHER"

If I add one or the other by itself into the select statement, then the query works fine. However, when I add the OR statement and try to use both statements in the select, I get an “Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access” error.

I’ve seen the other questions about this error and in those cases they rename one of the statements (ex. WorkType, Work_Type) in order to fix the problem. However, Worktype is the name of my output field so I need to have both be WorkType.

Any ideas?

  • 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-06-05T17:05:40+00:00Added an answer on June 5, 2026 at 5:05 pm

    Solution :

    it should be

    WorkType = groupItem.Key.Id.Contains("Correct") ? "Corrective" :
        (groupItem.Key.Id.Contains("Pred") ? "Preventative" : "OTHER");
    

    Problem:

    because problem with your code is

    WorkType = groupItem.Key.Id.Contains("Correct") ? "Corrective" : "OTHER" ||  
    WorkType = groupItem.Key.Id.Contains("Pred") ? "Preventative" : "OTHER"
    

    you are assigning value to worktype two time which is nopt possible

    And even if you write the code like

    WorkType = (groupItem.Key.Id.Contains("Correct") ? "Corrective" : "OTHER") ||  
              ( groupItem.Key.Id.Contains("Pred") ? "Preventative" : "OTHER");
    

    this will return boolean value either true or false…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL statement: Select Choose(1,Orders.Employee, Orders.Customer) as Name1, Choose(2,Orders.Employee, Orders.Customer) as
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
Hi I have following sql statement that gives me the the first_name and total
I have the following SQL statement which seems to be deleting every row in
I have the following SQL Query. SELECT MIN(PLD.available_date) as 'FROM', MAX(PLD.available_date) as 'UNTIL', (
I have the following SQL: SELECT `table1`.`value`, `table2`.* FROM `table2` INNER JOIN `table1` ON
I have the following code snippet: PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i =
I have the PL/SQL code that is similar to the following snippet: create or
I have following SQL query: SELECT Count(*) AS CountOfRecs FROM tblAccount INNER JOIN tblAccountOwner
I have following SQL query: $readNews_SQLselect = SELECT ; $readNews_SQLselect .= live, content, user,

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.