本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmModel.EntityContainer方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.EntityContainer方法的具体用法?C# EdmModel.EntityContainer怎么用?C# EdmModel.EntityContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Edm.Library.EdmModel
的用法示例。
在下文中一共展示了EdmModel.EntityContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NullValueNonPropertyErrorTests
public void NullValueNonPropertyErrorTests()
{
EdmModel model = new EdmModel();
var entityType = model.EntityType("OwningType", "TestModel").KeyProperty("ID", EdmCoreModel.Instance.GetInt32(false) as EdmTypeReference);
model.EntityContainer("DefaultContainer");
var entitySet = model.EntitySet("EntitySet", entityType);
IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new[]
{
new PayloadReaderTestDescriptor(this.Settings)
{
DebugDescription = "null collection - should fail.",
PayloadEdmModel = model,
PayloadElement = PayloadBuilder.PrimitiveCollection().ExpectedCollectionItemType(EdmDataTypes.Int32)
.JsonRepresentation(
"{" +
"\"@odata.context\":\"http://odata.org/test/$metadata#Edm.Null\"" +
"}"),
ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightContextUriParser_ContextUriDoesNotMatchExpectedPayloadKind", "http://odata.org/test/$metadata#Edm.Null", "Collection")
},
new PayloadReaderTestDescriptor(this.Settings)
{
DebugDescription = "null entry - should fail.",
PayloadEdmModel = model,
PayloadElement = PayloadBuilder.NullEntity().ExpectedEntityType(entityType, entitySet)
.JsonRepresentation(
"{" +
"\"@odata.context\":\"http://odata.org/test/$metadata#Edm.Null\"" +
"}"),
ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightContextUriParser_ContextUriDoesNotMatchExpectedPayloadKind", "http://odata.org/test/$metadata#Edm.Null", "Entry")
},
new PayloadReaderTestDescriptor(this.Settings)
{
DebugDescription = "null feed - should fail.",
PayloadEdmModel = model,
PayloadElement = PayloadBuilder.EntitySet().ExpectedEntityType(entityType, entitySet)
.JsonRepresentation(
"{" +
"\"@odata.context\":\"http://odata.org/test/$metadata#Edm.Null\"" +
"}"),
ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightContextUriParser_ContextUriDoesNotMatchExpectedPayloadKind", "http://odata.org/test/$metadata#Edm.Null", "Feed")
},
};
this.CombinatorialEngineProvider.RunCombinations(
testDescriptors,
this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations,
(testDescriptor, testConfiguration) =>
{
if (testConfiguration.IsRequest)
{
return;
}
// These descriptors are already tailored specifically for Json Light and
// do not require normalization.
testDescriptor.TestDescriptorNormalizers.Clear();
testDescriptor.RunTest(testConfiguration);
});
}
示例2: ActionAndFunctionTest
public void ActionAndFunctionTest()
{
// <m:action Metadata=URI title?="title" target=URI />
Uri actionMetadata = new Uri("http://odata.org/test/$metadata#defaultAction");
Uri actionMetadata2 = new Uri("#action escaped relative metadata", UriKind.Relative);
Uri actionMetadata3 = new Uri("../#action escaped relative metadata", UriKind.Relative);
string actionTitle = "Default Action";
Uri actionTarget = new Uri("http://odata.org/defaultActionTarget");
Uri actionTarget2 = new Uri("http://odata.org/defaultActionTarget2");
ODataAction action_r1_t1 = new ODataAction() { Metadata = actionMetadata, Title = actionTitle, Target = actionTarget };
ODataAction action_r1_t2 = new ODataAction() { Metadata = actionMetadata, Title = actionTitle, Target = actionTarget2 };
ODataAction action_r2_t1 = new ODataAction() { Metadata = actionMetadata2, Title = actionTitle, Target = actionTarget };
ODataAction action_r3_t1 = new ODataAction() { Metadata = actionMetadata3, Title = actionTitle, Target = actionTarget };
Uri functionMetadata = new Uri("http://odata.org/test/$metadata#defaultFunction");
Uri functionMetadata2 = new Uri("#function escaped relative metadata", UriKind.Relative);
Uri functionMetadata3 = new Uri("\\#function escaped relative metadata", UriKind.Relative);
string functionTitle = "Default Function";
Uri functionTarget = new Uri("http://odata.org/defaultFunctionTarget");
Uri functionTarget2 = new Uri("http://odata.org/defaultFunctionTarget2");
ODataFunction function_r1_t1 = new ODataFunction() { Metadata = functionMetadata, Title = functionTitle, Target = functionTarget };
ODataFunction function_r1_t2 = new ODataFunction() { Metadata = functionMetadata, Title = functionTitle, Target = functionTarget2 };
ODataFunction function_r2_t1 = new ODataFunction() { Metadata = functionMetadata2, Title = functionTitle, Target = functionTarget };
ODataFunction function_r3_t1 = new ODataFunction() { Metadata = functionMetadata3, Title = functionTitle, Target = functionTarget };
var actionCases = new[]
{
new {
ODataActions = new ODataAction[] { action_r1_t1 },
Atom = GetAtom(action_r1_t1),
JsonLight = GetJsonLightForRelGroup(action_r1_t1),
},
new {
ODataActions = new ODataAction[] { action_r1_t1, action_r1_t2 },
Atom = GetAtom(action_r1_t1) + GetAtom(action_r1_t2),
JsonLight = GetJsonLightForRelGroup(action_r1_t1, action_r1_t2),
},
new {
ODataActions = new ODataAction[] { action_r1_t1, action_r2_t1 },
Atom = GetAtom(action_r1_t1) + GetAtom(action_r2_t1),
JsonLight = GetJsonLightForRelGroup(action_r1_t1) + "," + GetJsonLightForRelGroup(action_r2_t1),
},
new {
ODataActions = new ODataAction[] { action_r1_t1, action_r2_t1, action_r1_t2 },
Atom = GetAtom(action_r1_t1) + GetAtom(action_r2_t1) + GetAtom(action_r1_t2),
JsonLight = GetJsonLightForRelGroup(action_r1_t1, action_r1_t2) + "," + GetJsonLightForRelGroup(action_r2_t1),
},
new {
ODataActions = new ODataAction[] { action_r3_t1 },
Atom = GetAtom(action_r3_t1),
JsonLight = GetJsonLightForRelGroup(action_r3_t1),
},
};
var functionCases = new[]
{
new {
ODataFunctions = new ODataFunction[] { function_r1_t1 },
Atom = GetAtom(function_r1_t1),
JsonLight = GetJsonLightForRelGroup(function_r1_t1),
},
new {
ODataFunctions = new ODataFunction[] { function_r1_t1, function_r1_t2 },
Atom = GetAtom(function_r1_t1) + GetAtom(function_r1_t2),
JsonLight = GetJsonLightForRelGroup(function_r1_t1, function_r1_t2),
},
new {
ODataFunctions = new ODataFunction[] { function_r1_t1, function_r2_t1 },
Atom = GetAtom(function_r1_t1) + GetAtom(function_r2_t1),
JsonLight = GetJsonLightForRelGroup(function_r1_t1) + "," + GetJsonLightForRelGroup(function_r2_t1),
},
new {
ODataFunctions = new ODataFunction[] { function_r1_t1, function_r2_t1, function_r1_t2 },
Atom = GetAtom(function_r1_t1) + GetAtom(function_r2_t1) + GetAtom(function_r1_t2),
JsonLight = GetJsonLightForRelGroup(function_r1_t1, function_r1_t2) + "," + GetJsonLightForRelGroup(function_r2_t1),
},
new {
ODataFunctions = new ODataFunction[] { function_r3_t1 },
Atom = GetAtom(function_r3_t1),
JsonLight = GetJsonLightForRelGroup(function_r3_t1),
},
};
var queryResults =
from actionCase in actionCases
from functionCase in functionCases
select new
{
actionCase.ODataActions,
functionCase.ODataFunctions,
Atom = string.Concat(actionCase.Atom, functionCase.Atom),
JsonLight = string.Join(",", new[] { actionCase.JsonLight, functionCase.JsonLight }.Where(x => x != null))
};
EdmModel model = new EdmModel();
EdmEntityType edmEntityTypeCustomer = model.EntityType("Customer", "TestModel");
EdmEntityContainer edmEntityContainer = model.EntityContainer("DefaultContainer","TestModel" );
//.........这里部分代码省略.........