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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:35:38+00:00 2026-05-14T15:35:38+00:00

public ActionResult Index() { testEntities6 devicesEntities = new testEntities6(); List<DevicesModel> devicesModel = new List<DevicesModel>();

  • 0
public ActionResult Index()
    {
        testEntities6 devicesEntities = new testEntities6();
        List<DevicesModel> devicesModel = new List<DevicesModel>();
        var device_query = from d in devicesEntities.device
             join dt in devicesEntities.devicetype on d.DeviceTypeId equals dt.Id
             join l in devicesEntities.location on d.Id equals l.DeviceId
             join loc in devicesEntities.locationname on l.LocationNameId equals loc.Id
                           where l.DeviceId == d.Id
                           select new {
                               //devices
                               d.Id,
                               d.DeviceTypeId,
                               d.SerialNumber,
                               d.FirmwareRev,
                               d.ProductionDate,
                               d.ReparationDate,
                               d.DateOfLastCalibration,
                               d.DateOfLastCalibrationCheck,
                               d.CalCertificateFile,
                               d.Notes,
                               d.TestReportFile,
                               d.WarrantyFile,
                               d.CertificateOfOriginFile,
                               d.QCPermissionFile,
                               d.Reserved,
                               d.ReservedFor,
                               d.Weight,
                               d.Price,
                               d.SoftwareVersion,
                               //devicetype
                               dt.Name,
                               dt.ArticleNumber,
                               dt.Type,
                               //location
                               l.StartDate, //AS LastStartDate,
                               l.LocationNameId,
                               //locationname
                               Loc_name = loc.Name //AS CarrentLocation
                           };

        foreach (var dv in device_query) {
            devicesModel.Add(new DevicesModel(
                //device
                DeviceTypeId = dv.DeviceTypeId, 
      /*Why I have this error: The name 'DeviceTypeId' does not exist in the current context*/
                ...
                ));

        }
        return View(devicesModel);
    }

Model:

public class DevicesModel
 {
//device
public int deviceTypeId;
public int id;
public int serialNumber;
public string firmwareRev;
public DateTime productionDate;
public DateTime reparationDate;
public DateTime dateOfLastCalibration;
public DateTime dateOfLastCalibrationCheck;
public int calCertificateFile;
public string notes;
public int testReportFile;
public int warrantyFile;
public int certificateOfOriginFile;
public int qCPermissionFile;
public int BReserved;
public string reservedFor;
public double weight;
public int price;
public string softwareVersion;
//devicetype
public string name;
public string qrticleNumber;
public string type;
//location
public DateTime startDate;
public int locationNameId;
//locationname
public string loc_name;

public DevicesModel(){}

//device
public int DeviceTypeId{get;set;}
public int Id { get; set; }
public int SerialNumber { get; set; }
public string FirmwareRev { get; set; }
public DateTime ProductionDate { get; set; }
public DateTime ReparationDate { get; set; }
public DateTime DateOfLastCalibration { get; set; }
public DateTime DateOfLastCalibrationCheck { get; set; }
public int CalCertificateFile { get; set; }
public string Notes { get; set; }
public int TestReportFile { get; set; }
public int WarrantyFile { get; set; }
public int CertificateOfOriginFile { get; set; }
public int QCPermissionFile { get; set; }
public int bReserved { get; set; }
public string ReservedFor { get; set; }
public double Weight { get; set; }
public int Price { get; set; }
public string SoftwareVersion { get; set; }
//devicetype
public string Name { get; set; }
public string ArticleNumber { get; set; }
public string Type { get; set; }
//location
public DateTime StartDate { get; set; }
public int LocationNameId { get; set; }
//locationname
public string Loc_name { get; set; }
}
  • 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-14T15:35:38+00:00Added an answer on May 14, 2026 at 3:35 pm

    Its because you’re creating an anonymous object in your linq “Select” clause. I think you want to create an instance of your DevicesModel class, e.g.

    ...
    where l.DeviceId == d.Id
    select new DevicesModel {
    //devices
    Id = d.Id,
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public ActionResult Index(){ var dataContext = new DataEvidencijaDataContext(); MembershipUser myObject = Membership.GetUser(); string KorisnickoIme
I'm generating a CSV file from the following code public ActionResult Index() { var
I have this controller: public ActionResult Index(int id) { var cust = (from c
I have this code: EmployeeEntities storeDB = new EmployeeEntities(); public ActionResult Index() { var
Controller action: public ActionResult Index() { probaEntities proba = new probaEntities(); probaEntities proba1 =
Instead of: public ActionResult Index() { ViewData[foo] = _repository.GetFoos().ToList(); ViewData[bar] = new string[] {
I have a post action Import: public ActionResult Import() { var fileNames = new
public ActionResult Index() { int retCode = Errors.SUCCESS; var da = this.GetDataAccess(); var ids=
My code: public ActionResult Index() { IndexViewModel indexViewModel = new IndexViewModel(); indexViewModel.Questions = GetQuestions();
I have the following code: private Models.mediamanagerEntities dataModel = new Models.mediamanagerEntities(); public ActionResult Index(FormCollection

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.