本文整理汇总了C#中Microsoft.Test.Taupo.Contracts.EntityModel.EntityModelSchema.GetEntitySet方法的典型用法代码示例。如果您正苦于以下问题:C# EntityModelSchema.GetEntitySet方法的具体用法?C# EntityModelSchema.GetEntitySet怎么用?C# EntityModelSchema.GetEntitySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Test.Taupo.Contracts.EntityModel.EntityModelSchema
的用法示例。
在下文中一共展示了EntityModelSchema.GetEntitySet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateRequestOperation
private IHttpRequest GenerateRequestOperation(ODataResponse batchResponseOperation, EntityModelSchema model)
{
ExceptionUtilities.CheckArgumentNotNull(batchResponseOperation, "batchResponseOperation");
ExceptionUtilities.CheckArgumentNotNull(model, "model");
var headers = new Dictionary<string, string> { { "GivenPayloadRequestHeader", "PayloadHeaderValue" } };
string mergeContentType = HttpUtilities.BuildContentType(MimeTypes.ApplicationXml, Encoding.UTF8.WebName, null);
ODataUri uri = null;
HttpVerb verb = HttpVerb.Get;
if (batchResponseOperation.RootElement != null)
{
var complexInstanceCollection = batchResponseOperation.RootElement as ComplexInstanceCollection;
if (complexInstanceCollection != null)
{
var function = batchResponseOperation.RootElement.GetAnnotation<FunctionAnnotation>();
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.ServiceOperation(function.Function));
}
var complexMultivalue = batchResponseOperation.RootElement as ComplexMultiValueProperty;
if (complexMultivalue != null)
{
var entityType = complexMultivalue.GetAnnotation<EntityModelTypeAnnotation>().EntityModelType as EntityDataType;
var entitySet = model.GetEntitySet(entityType.Definition.Name);
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(entitySet), ODataUriBuilder.Property(entityType.Definition, complexMultivalue.Name));
}
var complexProperty = batchResponseOperation.RootElement as ComplexProperty;
if (complexProperty != null)
{
var type = complexProperty.GetAnnotation<EntityModelTypeAnnotation>();
var complexDataType = type.EntityModelType as ComplexDataType;
// Using first because we don't need a specific entity just one that contains this type. If there is more than one the first works fine.
var entityType = model.EntityTypes.Where(et => et.Properties.Where(p => p.Name == complexProperty.Name).Count() == 1).First();
var complexType = model.ComplexTypes.Where(ct => complexDataType.Definition.Name == ct.Name).Single();
var complexPropertyName = entityType.AllProperties.Where(p =>
{
var complex = p.PropertyType as ComplexDataType;
if (complex == null)
{
return false;
}
return complex.Definition.Name == complexDataType.Definition.Name;
}).Single();
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.Property(entityType, complexPropertyName.Name));
}
var deferredLink = batchResponseOperation.RootElement as DeferredLink;
if (deferredLink != null)
{
var navigationProperty = deferredLink.GetAnnotation<NavigationPropertyAnnotation>();
var entityType = model.EntityTypes.Where(et => et.Properties.Where(p => p.Name == navigationProperty.Property.Name).Count() == 1).First();
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.Property(entityType, navigationProperty.Property.Name));
}
var linkCollection = batchResponseOperation.RootElement as LinkCollection;
if (linkCollection != null)
{
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), SystemSegment.EntityReferenceLinks);
}
var entityInstance = batchResponseOperation.RootElement as EntityInstance;
if (entityInstance != null)
{
var type = entityInstance.GetAnnotation<EntityModelTypeAnnotation>().EntityModelType as EntityDataType;
var entitySetType = model.GetEntitySet(type.Definition.Name);
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(entitySetType));
}
var entitySetInstance = batchResponseOperation.RootElement as EntitySetInstance;
if (entitySetInstance != null)
{
var entitySetType = model.GetEntitySet(entityInstance.FullTypeName);
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(entitySetType));
}
var primitiveCollection = batchResponseOperation.RootElement as PrimitiveCollection;
if (primitiveCollection != null)
{
var function = batchResponseOperation.RootElement.GetAnnotation<FunctionAnnotation>();
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.ServiceOperation(function.Function));
}
var primitiveMultiValueProperty = batchResponseOperation.RootElement as PrimitiveMultiValueProperty;
if (primitiveMultiValueProperty != null)
{
var type = primitiveMultiValueProperty.GetAnnotation<EntityModelTypeAnnotation>();
var entityType = type.EntityModelType as EntityDataType;
uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(model.GetEntitySet(entityType.Definition.Name)), ODataUriBuilder.Property(entityType.Definition, primitiveMultiValueProperty.Name));
}
var primitiveProperty = batchResponseOperation.RootElement as PrimitiveProperty;
if (primitiveProperty != null)
{
var type = complexProperty.GetAnnotation<EntityModelTypeAnnotation>();
var entityType = type.EntityModelType as EntityDataType;
//.........这里部分代码省略.........