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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:45:12+00:00 2026-06-08T13:45:12+00:00

Within a WCF web service I make a query on a ORACLE 11g database

  • 0

Within a WCF web service I make a query on a ORACLE 11g database and I use entity framework as model. The target field is of type Numeric, while in the entity framework is Int64.

When I try to update the field I get the following exception: The specified cast from a materialized ‘System.Decimal’ type to the ‘System.Int64’ type is not valid.
The method generating the error is below, in particular for the line within the else statement: result = _context.ExecuteStoreQuery(query).FirstOrDefault();

public string GetDatabaseTimestamp(Type timestampFieldType, string query)
{
    object result;

    if (timestampFieldType == typeof(string))
    {
        result = _context.ExecuteStoreQuery<string>(query).FirstOrDefault();
    }
    else
    {
        result = _context.ExecuteStoreQuery<long>(query).FirstOrDefault();
    }

    return result.ToString();
}

Would it be possible to define at the EF level a converter or something similar? The option of changing the Database is not feasible, therefore I have to edit code.

  • 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-08T13:45:13+00:00Added an answer on June 8, 2026 at 1:45 pm

    In The EF I already changed the type into decimal. Problem is that the query was executed directly on the Oracle database and this was generating the exception.

    I solved the issue by using attributes for the target entity and changed the method into:

    public string GetDatabaseTimestamp(Type timestampFieldType, string query) 
    { 
     object result; 
    
    if (timestampFieldType == typeof(string)) 
    { 
      result = _context.ExecuteStoreQuery<string>(query).FirstOrDefault(); 
    } 
    else if (timestampFieldType == typeof(decimal)) 
    { 
      result = _context.ExecuteStoreQuery<decimal>(query).FirstOrDefault(); 
    } 
    else 
    {  
      result = _context.ExecuteStoreQuery<long>(query).FirstOrDefault(); 
    } 
    
    return result.ToString(); 
    } 
    

    In this way the passed timestampFieldType is of type decimal and the proper cast is selected. This issue is due to different data types used for similar fields (as example Update fields) in the Oracle DB (legacy database).

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

Sidebar

Related Questions

I'm working on a new WCF web service that's to be hosted within an
I'm trying to make a call to a remote WCF service from within an
i have the WCF web service within my solution. service has interface which implemeted
I am currently trying to use a web service I developed within an Integration
I need to call a RabbitMQ RPC Service from within a C# WCF Web
Scenario : Web Site project under .NET 3.5 Visual Studio 2010 WCF Service reference
I'm interested in properly handling Faults within a WCF REST Service client. While using
I have made a REST Web service, that works with Visual Studios WCF Test
I have created a WCF web service in C# deployed in a Windows Service
I am building a Web service using WCF as a way to provide access

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.