Update CRM ntext fields and other question

Jan 22, 2010 at 10:59 AM

Kurt,

Am i right when i say there is no Update implementation for a CRM ntext field; I get it returned as a String, add for instance "\r\nGood Morning all" to it and do a Update -> error comes back.

Another question:

In a QueryExpression we use { ColumnSet = new AllColumns() }; can this AllColumns() be replaced by something related to the Class e.g. the fields mapped in the Class. Letter: IXrmEntity

regards, Bob.

Coordinator
Jan 25, 2010 at 5:54 PM

Hi Bob,

I have tested with ntext and it seems to work as expected my end. If you post the InnerText of the soap exception you get on the Update then I may be able to help.

As for the ColumnSet, I have pushed a version up which includes an XrmMappedColumnSet which works similarly to a ColumnSet - additionally, it exposes a constructor that accepts an IXrmEntity. Originally, I didn't add this as I couldn't derive from ColumnSetBase as intented (long story short.. I wasn't able to have my inherited class serialize correctly) I worked around this for now by adding an implicit operator that allows the type to cast to a ColumnSet. Now, it can be used like:

{ ColumnSet = new XrmMappedColumns(myXrmEntity) };
This, however, can be left out as the RetrieveMultiple<T>, in the latest version, of the toolkit has logic to create a columnset at run-time (it will build a ColumnSet that has all the attributes used in the type) - here's a snippit of what it's doing:

if (query.ColumnSet == null || query.ColumnSet.GetType() == typeof(AllColumns))
    query.ColumnSet = new XrmMappedColumnSet(attributes.Select(s => s.Key).ToArray());
Hope I explained that OK, let me know if you need clarification.

Thanks,

Kurt


            if (query.ColumnSet == null || query.ColumnSet.GetType() == typeof(AllColumns))
                query.ColumnSet = new XrmMappedColumnSet(attributes.Select(s => s.Key).ToArray());