【发布时间】:2017-09-08 13:32:22
【问题描述】:
我有一个 azure 函数,我想从 Azure 表中获取数据,然后将其推送到 CRM。在 CRM 中创建记录很容易,但我不确定如何正确访问表格。
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Client.Services;
public static void Run(TimerInfo myTimer, Lead lead, TraceWriter log)
{
var connectionString = "AuthType=Office365;Username=*****; Password=****;Url=*****";
CrmConnection connection = CrmConnection.Parse(connectionString);
using (OrganizationService orgService = new OrganizationService(connection))
{
try
{
var query = new QueryExpression("account");
query.ColumnSet.AddColumns("name");
var ec = orgService.RetrieveMultiple(query);
log.Verbose(ec[0].GetAttributeValue<string>("name"));
Lead lead = new Lead();
string name = lead.LeadSource;
Console.WriteLine("name is: {0}", name);
//log.Verbose($"Name in Person entity: {lead.Name}");
}
catch (ArgumentNullException e)
{
Console.WriteLine("{0} First exception caught.", e);
}
}
}
public class Lead
{
public string PartitionKey {get; set;}
public string RowKey { get; set; }
public string Name { get; set; }
public string ProductId {get; set;}
public string CustomerInfo {get; set;}
public string LeadSource {get; set;}
public string ActionCode {get; set;}
public string PublisherDisplayName {get; set;}
public string OfferDisplayName {get; set;}
public string CreatedTime {get; set;}
public string Description {get; set;}
}
在行中:
Lead lead = new Lead();
string name = lead.LeadSource;
Console.WriteLine("name is: {0}", name);
我希望从数据集中打印leadsource 的指定值,但它什么也不输出。
【问题讨论】:
标签: c# azure dynamics-crm azure-storage azure-functions