This question is locked. New answers and comments are not allowed.
I have hit an issue and can't seem to understand why it is throwing the following error:
Mapping the result to instances of the class 'CRERNS_ORMData.TelephoneReport' failed because the required primary key column '' is not present.
I am executing this code through a dll in both a web and windows project. The web app runs it fine, no errors and returns the data expected. The windows app is throwing the error listed above. Here is my code:
IQuery q1 = sc.GetSqlQuery(@"SELECT [TelephoneReportID] ,[FacilityID] ,[FacilityName] ,[FirstName] ,[LastName] ,[Company] ,[DateTimeReceived] ,[Phone] ,[Comments] ,[ReportingState] ,[ERNSNumber] ,[FacilityAddress] ,[FacilityCity] ,[FacilityState] ,[ChemicalOfConcern] ,[ChemicalOfConcernComments] FROM [CRERNS].[dbo].[TelephoneReports] WHERE [FacilityID] is null ORDER BY DatetimeReceived DESC", typeof(TelephoneReport), null);var telephoneReports = DataDriver.Utilities.ToList<TelephoneReport>(q1.Execute().ToList());If it matters, I have a utility that converts the results to a list:
public static class Utilities{ public static List<T> ToList<T>(ArrayList arrayList) { List<T> list = new List<T>(arrayList.Count); foreach (T instance in arrayList) { list.Add(instance); } return list; }}Telephone Report class is below:
using System;namespace CRERNS_ORMData { // Generated by Telerik OpenAccess // Used template: c:\program files (x86)\telerik\openaccess orm\sdk\IDEIntegrations\templates\PCClassGeneration\cs\templates\classgen\class\partialdesignerdefault.vm [Telerik.OpenAccess.Persistent(IdentityField="telephoneReportID")] public partial class TelephoneReport { private Guid telephoneReportID; // pk private string comments; private string company; private DateTime dateTimeReceived; private Guid? facilityID; private string facilityName; private string firstName; private string lastName; private string phone; private string reportingState; private Facility facility; private string eRNSNumber; private string facilityAddress; private string facilityCity; private string facilityState; private string chemicalOfConcern; private string chemicalOfConcernComments; }}#region main class file contents/*using System;using System.Collections.Generic;namespace CRERNS_ORMData { //Generated by Telerik OpenAccess public partial class TelephoneReport { //The 'no-args' constructor required by OpenAccess. public TelephoneReport() { } [Telerik.OpenAccess.FieldAlias("telephoneReportID")] public Guid TelephoneReportID { get { return telephoneReportID; } set { this.telephoneReportID = value; } } [Telerik.OpenAccess.FieldAlias("comments")] public string Comments { get { return comments; } set { this.comments = value; } } [Telerik.OpenAccess.FieldAlias("company")] public string Company { get { return company; } set { this.company = value; } } [Telerik.OpenAccess.FieldAlias("dateTimeReceived")] public DateTime DateTimeReceived { get { return dateTimeReceived; } set { this.dateTimeReceived = value; } } [Telerik.OpenAccess.FieldAlias("facilityID")] public Guid? FacilityID { get { return facilityID; } set { this.facilityID = value; } } [Telerik.OpenAccess.FieldAlias("facilityName")] public string FacilityName { get { return facilityName; } set { this.facilityName = value; } } [Telerik.OpenAccess.FieldAlias("firstName")] public string FirstName { get { return firstName; } set { this.firstName = value; } } [Telerik.OpenAccess.FieldAlias("lastName")] public string LastName { get { return lastName; } set { this.lastName = value; } } [Telerik.OpenAccess.FieldAlias("phone")] public string Phone { get { return phone; } set { this.phone = value; } } [Telerik.OpenAccess.FieldAlias("reportingState")] public string ReportingState { get { return reportingState; } set { this.reportingState = value; } } [Telerik.OpenAccess.FieldAlias("facility")] public Facility Facility { get { return facility; } set { this.facility = value; } } }}*/#endregion //main class file contentsusing System;namespace CRERNS_ORMData{ // Generated by Telerik OpenAccess // Used template: c:\program files (x86)\telerik\openaccess orm\sdk\IDEIntegrations\templates\PCClassGeneration\cs\templates\classgen\class\partialuserdefault.vm // NOTE: Field declarations and 'Object ID' class implementation are added to the 'designer' file. // Changes made to the 'designer' file will be overwritten by the wizard. public partial class TelephoneReport { //The 'no-args' constructor required by OpenAccess. public TelephoneReport() { } [Telerik.OpenAccess.FieldAlias("telephoneReportID")] public Guid TelephoneReportID { get { return telephoneReportID; } set { this.telephoneReportID = value; } } [Telerik.OpenAccess.FieldAlias("comments")] public string Comments { get { return comments; } set { this.comments = value; } } [Telerik.OpenAccess.FieldAlias("company")] public string Company { get { return company; } set { this.company = value; } } [Telerik.OpenAccess.FieldAlias("dateTimeReceived")] public DateTime DateTimeReceived { get { return dateTimeReceived; } set { this.dateTimeReceived = value; } } [Telerik.OpenAccess.FieldAlias("facilityID")] public Guid? FacilityID { get { return facilityID; } set { this.facilityID = value; } } [Telerik.OpenAccess.FieldAlias("facilityName")] public string FacilityName { get { return facilityName; } set { this.facilityName = value; } } [Telerik.OpenAccess.FieldAlias("firstName")] public string FirstName { get { return firstName; } set { this.firstName = value; } } [Telerik.OpenAccess.FieldAlias("lastName")] public string LastName { get { return lastName; } set { this.lastName = value; } } [Telerik.OpenAccess.FieldAlias("phone")] public string Phone { get { return phone; } set { this.phone = value; } } [Telerik.OpenAccess.FieldAlias("reportingState")] public string ReportingState { get { return reportingState; } set { this.reportingState = value; } } [Telerik.OpenAccess.FieldAlias("facility")] public Facility Facility { get { return facility; } set { this.facility = value; } } [Telerik.OpenAccess.FieldAlias("ernsNumber")] public string ERNSNumber { get { return eRNSNumber; } set { this.eRNSNumber = value; } } [Telerik.OpenAccess.FieldAlias("facilityAddress")] public string FacilityAddress { get { return facilityAddress; } set { this.facilityAddress = value; } } [Telerik.OpenAccess.FieldAlias("facilityCity")] public string FacilityCity { get { return facilityCity; } set { this.facilityCity = value; } } [Telerik.OpenAccess.FieldAlias("facilityState")] public string FacilityState { get { return facilityState; } set { this.facilityState = value; } } [Telerik.OpenAccess.FieldAlias("chemicalOfConcern")] public string ChemicalOfConcern { get { return chemicalOfConcern; } set { this.chemicalOfConcern = value; } } [Telerik.OpenAccess.FieldAlias("chemicalOfConcernComments")] public string ChemicalOfConcernComments { get { return chemicalOfConcernComments; } set { this.chemicalOfConcernComments = value; } } }}I am using OpenAccess 2011.2.713.3 in all three of my projects. My best guess is that it is not getting the primary key column since the error message has an empty quote before "is not present". I am befuddled.....
Any ideas??