Mapping the result to instances of the class 'CRERNS_ORMData.TelephoneReport' failed because the required primary key column '' is not present.

8 posts, 0 answers
  1. Kris
    Kris avatar
    47 posts
    Member since:
    Feb 2008

    Posted 09 Nov 2011 Link to this post


    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 contents


    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\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??
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 14 Nov 2011 Link to this post

    Hi Kris,

    We tried to reproduce the problem using a similar class but unfortunately with no success. Could you please open a support ticket and attach there the project with your model? Hopefully it would help us to reproduce the issue and find what goes wrong.
    Thank you in advance for your cooperation.

    Best wishes,
    Alexander
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

  3. DevCraft banner
  4. Kris
    Kris avatar
    47 posts
    Member since:
    Feb 2008

    Posted 14 Nov 2011 Link to this post

    I have opened support ticket #482851 for your reference

    Thanks
  5. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 15 Nov 2011 Link to this post

    Hello Kris,

    Thank you for sending the project, we will look into it and notify you as soon as we have more information about the problem.

    All the best,
    Alexander
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

  6. Marshal
    Marshal avatar
    3 posts
    Member since:
    Nov 2012

    Posted 28 Jan 2013 Link to this post

    Am also facing similar issue on SIT server but it is not coming in DEV box.
    please advice?
    thanks
    Marshal
  7. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 31 Jan 2013 Link to this post

    Hello Masrhal,

    Kris' problem was caused by a missing reference from the executable project to the project containing the OpenAccess model.
    I assume that the problem in your case could also be caused by a missing reference, or most likely the assembly with your persistent classes is not loaded correctly on the deployment server. If possible, please verify that all assemblies are loaded correctly on the server.

    Kind regards,
    Alexander
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  8. Marshal
    Marshal avatar
    3 posts
    Member since:
    Nov 2012

    Posted 01 Feb 2013 Link to this post

    Dear Alex
    We are using DAL layer in sharepoint application and all references are added otherwise project will not build.
    Application works well after deployment but after few days of use we start getting this error.
    and then if we do iisreset it works well without any issue and then after few days again we get this issue?

    Any hint?
    here is the stack trace
    Exception message: Mapping the result to instances of the class 'ABC.CC.BP.ORM.VW_BP_EmployeeRoleList' failed because the required primary key column '' is not present.

     

    OpenAccessRuntime.ExceptionWrapper.Throw()
       at OpenAccessRuntime.storagemanager.logging.LoggingStorageManager.fetchNextQueryResult(ApplicationContext context, RunningQuery runningQuery, Int32 skipAmount)
       at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.getNextQueryResult(QueryResultWrapper aQrs, Int32 skipAmount)
       at OpenAccessRuntime.DataObjects.QueryIterator.GetMoreData()
       at OpenAccessRuntime.DataObjects.QueryIterator.MoveNext()
    at Telerik.OpenAccess.RT.TypedEnumerator`1.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)


    Regards
    Marshal
  9. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 06 Feb 2013 Link to this post

    Hello Masrhal,

    This error seems to be caused by a type mismatch (wrong persistent type is loaded) or the needed metadata for this class is missing. Is it possible that the moment this error occurs is the first time when the VW_BP_EmployeeRoleList class is used in the application, although it takes a few days to occur? Does it always occur for the same class and on the same place in code?

    Kind regards,
    Alexander
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Back to Top
DevCraft banner