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

  • Home
  • SEARCH
  • 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 8479985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:11:09+00:00 2026-06-10T19:11:09+00:00

When I am trying to Query Databae Context using Linq to Entities I am

  • 0

When I am trying to Query Databae Context using Linq to Entities I am getting this Exception.
LINQ to Entities does not recognize the method ‘Int32 Int32(System.String)’ method, and this method cannot be translated into a store expression.

Please help.
Thanks in Advance

                if (Request.Form["Enroll"] != null)
                {
                    string[] selected = Request.Form["Enroll"].Split(',');

                    if (selected != null)
                    {
                        if (selected.Count() != 0)
                        {
                            int k = 0;
                            foreach (var item in selected)
                            {
                                var id = db.EnrollTrainee.Where(i => i.TraineeID ==          Convert.ToInt32(item[k].ToString())
                                         && i.TrainerID == Convert.ToInt32(Session["user"].ToString()));
                                if (id != null)
                                {
                                    foreach (var a in id)//Getting Exception Here
                                    {
                                        enroll.id = a.id;
                                        db.EnrollTrainee.Remove(enroll);
                                        db.SaveChanges();                                           
                                    }
                                }
                                k++;
                            }
                        }
                    }
  • 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-10T19:11:11+00:00Added an answer on June 10, 2026 at 7:11 pm

    Have you tried doing the conversion before you do the linq?

    So like this:

      foreach (var item in selected)
      {
            var tempId = Convert.ToInt32(item[k].ToString());
            var tempId2 = Convert.ToInt32(Session["user"].ToString());
            var id = db.EnrollTrainee.Where(i => i.TraineeID == tempId         
                                         && i.TrainerID == tempId2);
                                if (id != null)
                                {
                                    foreach (var a in id)//Getting Exception Here
                                    {
                                        enroll.id = a.id;
                                        db.EnrollTrainee.Remove(enroll);
                                        db.SaveChanges();                                           
                                    }
                                }
                                k++;
                            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Entity Framework with Linq to Entities, trying to select some data
I'm trying to remove object from my context using the remove method. But i
I'm trying to query a database view that's not located on the same server
I'm trying to query a MySQL database using an array but I'm having trouble!
I am trying to query some tables in my database using a simple dropdown
I've really been trying, but I am just not getting blocks very well. I
I'm just starting out with LINQ to Entities, and I'm trying to replicate a
I'm trying to start using LINQ and specifically LINQ to SQL but I'm having
I am trying to delete a specific row in database. Using the following query:
I'm trying to run a no tracking query on my entities so that I

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.