本文整理汇总了C#中EntityKey.ToQuery方法的典型用法代码示例。如果您正苦于以下问题:C# EntityKey.ToQuery方法的具体用法?C# EntityKey.ToQuery怎么用?C# EntityKey.ToQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityKey
的用法示例。
在下文中一共展示了EntityKey.ToQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchByKey
public async Task FetchByKey() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<Fruit>().From("Fruits");
var r0 = await em1.ExecuteQuery(q);
Assert.IsTrue(r0.Count() > 0);
var fruit1 = r0.First();
var id = fruit1.Id;
var ek = new EntityKey(typeof(Fruit), em1.MetadataStore, id);
var r1 = await em1.ExecuteQuery(ek.ToQuery());
var fruits = r1.Cast<Fruit>();
Assert.IsTrue(fruits.First() == fruit1);
}
示例2: FetchByKeyWithDefaultResource
public async Task FetchByKeyWithDefaultResource() {
var em1 = await TestFns.NewEm(_serviceName);
var rn = em1.MetadataStore.GetDefaultResourceName(typeof(Fruit));
Assert.IsTrue(rn != "Fruits");
em1.MetadataStore.SetResourceName("Fruits", typeof(Fruit), true);
var rn2 = em1.MetadataStore.GetDefaultResourceName(typeof(Fruit));
Assert.IsTrue(rn2 == "Fruits");
var q = new EntityQuery<Fruit>();
var r0 = await em1.ExecuteQuery(q);
Assert.IsTrue(r0.Count() > 0);
var fruit1 = r0.First();
var id = fruit1.Id;
var ek = new EntityKey(typeof(Fruit), em1.MetadataStore, id);
var r1 = await em1.ExecuteQuery(ek.ToQuery());
var fruits = r1.Cast<Fruit>();
Assert.IsTrue(fruits.First() == fruit1);
}
示例3: FetchByAbstractEntityKey
public async Task FetchByAbstractEntityKey() {
var em1 = await TestFns.NewEm(_serviceName);
var q = new EntityQuery<ItemOfProduce>().From("ItemsOfProduce");
var r0 = await em1.ExecuteQuery(q);
Assert.IsTrue(r0.Count() > 0);
var iop1 = r0.First();
var id = iop1.Id;
var ek = new EntityKey(typeof(ItemOfProduce), em1.MetadataStore, id);
var r1 = await em1.ExecuteQuery(ek.ToQuery());
var fruits = r1.Cast<ItemOfProduce>();
Assert.IsTrue(fruits.First() == iop1);
}
示例4: FetchEntityByKeyItemOfProduce
public async Task FetchEntityByKeyItemOfProduce() {
var em1 = await TestFns.NewEm(_serviceName);
var appleId = new Guid("13f1c9f5-3189-45fa-ba6e-13314fafaa92");
// var appleId = new Guid("D35E9669-2BAE-4D69-A27A-252B31800B74");
var ek = new EntityKey(typeof(ItemOfProduce), em1.MetadataStore, appleId);
var fr = await em1.FetchEntityByKey(ek);
Assert.IsTrue(fr.Entity != null && fr.Entity is Apple && !fr.FromCache);
// and again
var r0 = await em1.ExecuteQuery(ek.ToQuery<ItemOfProduce>());
Assert.IsTrue(r0.Count() > 0);
Assert.IsTrue(r0.First().Id == appleId);
}