在 Common Data Services SDKMicrosoft.CommonDataService
中,我可以使用此代码从数据库中选择实体
// Specify the generic object to retrieve
var genericEntitySet = client.GetRelationalEntitySet(
new EntitySetReference("Microsoft.CommonDataService.CommonEntities",
AdvEntity.EntityName,
Microsoft.CommonDataService.Version.Create("1.0.0")));
// Specify the required fields
var query = genericEntitySet.CreateQueryBuilder()
.Project(pc =>
pc
.SelectField(f => f["PrimaryId"])
.SelectField(f => f["Project_Title"])
.SelectField(f => f["CreatedByUser"])
.SelectField(f => f["CreatedOnDateTime"])
.SelectField(f => f["LastModifiedByUser"])
.SelectField(f => f["LastModifiedDateTime"])
.SelectField(f => f["Opportuinity"])
.SelectField(f => f["BNB"])
.SelectField(f => f["SP_URL"])
.SelectField(f => f["ProjectMgr"])
.SelectField(f => f["WorkTeam"])
.SelectField(f => f["BnB_ID"])
.SelectField(f => f["Custodian"])
.SelectField(f => f["Stage"])
.SelectField(f => f["Opp_Status"])
.SelectField(f => f["Confidential"])
.SelectField(f => f["CRMT_Num"])
.SelectField(f => f["Proj_Num"])
.SelectField(f => f["Sector"])
.SelectField(f => f["Service"])
.SelectField(f => f["Archive"])
);
var selectExecutor = client.CreateRelationalBatchExecuter(
RelationalBatchExecutionMode.Transactional);
await selectExecutor
.Query(query, out OperationResult<IReadOnlyList<RelationalEntity>> queryResult)
.ExecuteAsync();
但是,必须为我可能需要检索的每种类型的对象选择所有这些字段似乎很麻烦。
有没有办法告诉代码获取所有属性?
该文件指出
请注意,出于性能原因,没有自动选择所有字段的选项。
这个 SDK 是预览版,所以没有太多关于它的信息,但也许有人知道这个技巧?