Update to v1.5.2 with native count support
We have issued an update to v1.5.2 with two new features. Native count support through fetchxml and the ability to clone an entity.
Counting records
You can now call .Count() on any query and get the record count back without calling .ToList() first. This will only work if you are querying through fetchxml, query expressions has no support for counting records.
var count = (from a in context.Contacts select a.ContactId).Count();
Console.WriteLine(count);
The generated fetchxml will look like this
<fetch mapping="logical" aggregate="true">
<entity name="contact">
<attribute name="contactid" aggregate="count" alias="contactid_count" />
</entity>
</fetch>
Cloning a record
Thanks to Christian for coming up with this idea. You are now able to call the Clone method on any crm entity. We will only clone properties that have the CrmFieldAttribute; which means it will not clone any relationships (related records).
Here is an example
var contacts = (from a in context.Contacts select a).ToList();
for (int i = 0; i < contacts.Count; i++)
{
var cloned = contacts[i].Clone<Contact>();
cloned.ContactId = Guid.NewGuid(); // make sure you assign a new primary key
context.Create<Contact>(cloned);
}
You can download the update by logging into our portal.





Try XrmLinq