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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:51:10+00:00 2026-06-01T03:51:10+00:00

I want to insert into my table a column named ‘S’ that will get

  • 0

I want to insert into my table a column named ‘S’ that will get some string value based on a value it gets from a table column.

For example: for each ID (a.z) I want to gets it’s string value stored in another table. The string value is returned from another method that gets it through a Linq query.

  • Is it possible to call a method from Linq?
  • Should I do everything in the same query?

This is the structure of the information I need to get:

a.z is the ID in the first square in table #1, from this ID I get another id in table #2, and from that I can get my string value that I need to display under column ‘S’.
enter image description here

var q = (from a in v.A join b in v.B
    on a.i equals b.j
    where a.k == "aaa" && a.h == 0
    select new {T = a.i, S = someMethod(a.z).ToString()})
    return q;

The line S = someMethod(a.z).ToString() causing the following error:

Unable to cast object of type ‘System.Data.Linq.SqlClient.SqlColumn’
to type ‘System.Data.Linq.SqlClient.SqlMethodCall’.

  • 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-01T03:51:11+00:00Added an answer on June 1, 2026 at 3:51 am

    You have to execute your method call in Linq-to-Objects context, because on the database side that method call will not make sense – you can do this using AsEnumerable() – basically the rest of the query will then be evaluated as an in memory collection using Linq-to-Objects and you can use method calls as expected:

    var q = (from a in v.A join b in v.B
            on a.i equals b.j
            where a.k == "aaa" && a.h == 0
            select new {T = a.i, Z = a.z })
            .AsEnumerable()
            .Select(x => new { T = x.T, S = someMethod(x.Z).ToString() })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert data into a table where I don't know the next
I want to do some quick inserts but avoid duplicates into a Table. For
I want to insert into a table the following information: Week NoTrans Spend 02.01.12-08.01.12
I have a user table. I want to insert data into my user table.
I have a table called Events that I want to insert information to. Here
I have a table that has a column named 'languages', but it has the
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
So I'm doing a lot of inserts which only I want to insert into
I want to insert data into the postgresql database of OpenERP, I am able
When using Microsoft office automation I want to insert images into a spreadsheet. How

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.