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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:14:06+00:00 2026-05-16T00:14:06+00:00

public ActionResult ReadXMLDevices(int groupID) { var query = from k in XMLEntities.unassigneditems where k.DevOrAcc

  • 0
public ActionResult ReadXMLDevices(int groupID)
{             
    var query = from k in XMLEntities.unassigneditems
    where k.DevOrAcc == true && k.Group == groupID
    select k;

    var view_query = from i in query
                     select new GetFreeDevices
                     {
                         MArticleNumber = i.ArticleNumber,
                         MFirmware = i.Firmware,
                         MGroup = i.Group,
                         MName = i.Name,
                         MSoftware = i.SoftwareVersion,
                         SA = GetNumberOfDevices(i.ArticleNumber,2),
                         STH = GetNumberOfDevices(i.ArticleNumber,3),
                         SASTH = GetNumberOfDevices(i.ArticleNumber,7)
                     };
    return PartialView(view_query);
}

public int GetNumberOfDevices(string artNo,int loc)
{
    var num_dev = (from k in XMLEntities.deviceview
                   where k.Reserved == false && k.Sold == false && k.LocationNameId == loc && k.ArticleNumber == artNo
                   select k).Count();
    return num_dev;
}

Error:

LINQ to Entities does not recognize the method ‘Int32 GetNumberOfDevices(System.String, Int32)’ method, and this method cannot be translated into a store expression. How to resolve this???

  • 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-16T00:14:06+00:00Added an answer on May 16, 2026 at 12:14 am

    You can split your query in two to make sure the list is in-memory before calling the GetNumberOfDevices() method. You can make a query in-memory by converting the results to a List, or in this case a List<GetFreeDevices>. That way, LinQ to Entities does not have to do any translations to and from XML and you can use your GetNumberOfDevices() method.

    var view_query = (from i in query
         select new GetFreeDevices
         {
            MArticleNumber = i.ArticleNumber,
            MFirmware = i.Firmware,
            MGroup = i.Group,
            MName = i.Name,
            MSoftware = i.SoftwareVersion
    
         }).ToList();
    var result_query = from i in query
         select new GetFreeDevices
         {
            MArticleNumber = i.MArticleNumber,
            MFirmware = i.MFirmware,
            MGroup = i.MGroup,
            MName = i.MName,
            MSoftware = i.MSoftware,
            SA = GetNumberOfDevices(i.MArticleNumber,2),
            STH = GetNumberOfDevices(i.MArticleNumber,3),
            SASTH = GetNumberOfDevices(i.MArticleNumber,7)
         };
    return PartialView(result_query);
    

    Please note that the last statement requires the PartialView to accept a list or IEnumerable instead of an IQueryable.

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

Sidebar

Related Questions

// GET: /Product/Delete/5 public ActionResult Delete(int id) { var res = (from r in
I have this controller: public ActionResult Index(int id) { var cust = (from c
[AcceptVerbs(HttpVerbs.Get)] public ActionResult Delete(int id) { CustomerDataContext cs = new CustomerDataContext(); var query =
public ActionResult Create() { try { var Group = GroupRepository.FindAllGroups(); ViewData[Group] = GroupRepository.FindAllGroups(); ViewData[Feature]
public ActionResult DeleteCategory(int id) { CategoryManager manager = new CategoryManager(); manager.DeleteCategory(id); TempData[IsDeleted] = true;
public ActionResult Index() { int retCode = Errors.SUCCESS; var da = this.GetDataAccess(); var ids=
public ActionResult SomeAction(int Id){ //Id is set to 2 var model = //get some
public ActionResult GeneratePdf(int id) { var labelRepository = new LabelRepository(); var label = labelRepository.GetLabel(id);
Here is my code: public ActionResult DeleteItem(int id) { using (var cont = new
my controller action: [HttpPost] public ActionResult AddPointAndCopyOtherSongToPlaylist(int id) { if (CheckIfAddPointToSelf(User.Identity.Name, id)) { var

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.