locked
'Microsoft.Xrm.Sdk.Query.ColumnSet' does not contain a definition for 'Attributes' RRS feed

  • Question

  • Hi ,

    I am trying to download notes using bellow  code 

    public byte[] DownloadAttachment(string AnnotationId)
            {
              
               
                Guid annotationId = new Guid( AnnotationId );
    
                // Define the columns to retrieve from the annotation record.
                ColumnSet cols1 = new ColumnSet();
                cols1.Attributes = new string[] { "filename", "documentbody" };
    
                // Retrieve the annotation record.
                annotation annotationAttachment = (annotation)crmService.Retrieve(EntityName.annotation.ToString(), annotationId, cols1);
    
               
                using (FileStream fileStream = new FileStream(annotationAttachment.filename, FileMode.OpenOrCreate))
                {
                    byte[] fileContent = new UTF8Encoding(true).GetBytes(annotationAttachment.documentbody);
                //    fileStream.Write(fileContent, 0, fileContent.Length);
    
                    return fileContent;
                }
               
            }
    

    From Downloading Notes in MS CRM

    i am getting error in bellow line 

     // Define the columns to retrieve from the annotation record.
                ColumnSet cols1 = new ColumnSet();
                cols1.Attributes = new string[] { "filename", "documentbody" };
    

    Error : 

    'Microsoft.Xrm.Sdk.Query.ColumnSet' does not contain a definition for 'Attributes' and no extension method 'Attributes' accepting a first argument of type 'Microsoft.Xrm.Sdk.Query.ColumnSet' could be found (are you missing a using directive or an assembly reference?)


    Grateful for any help!!

    Wednesday, November 6, 2013 10:24 AM

All replies

  • That code is CRM 4.0 style, I think you are using CRM 2011.
    try with:
     ColumnSet cols1 = new ColumnSet("filename", "documentbody");

    to define the columnset (so only 1 row instead of 2 as your code)



    My blog: www.crmanswers.net - Rockstar 365 Profile



    Wednesday, November 6, 2013 11:39 AM