Quantcast
Channel: ASP.NET MVC / Web API / Web Pages
Viewing all 7925 articles
Browse latest View live

Created Issue: Delta doesn't support abstract class [450]

$
0
0
As we are supporting abstract base type, we should make Delta<T> to support abstract as well.

Current definition of Delta<T> is:

public class Delta<TEntityType> : DynamicObject, IDelta<TEntityType>, IDelta where TEntityType : class, new()

Created Issue: Delta doesn't work base type [451]

$
0
0
For example, I have controller class:
public class MotorcyclesController : ApiController
{
public void Put(Delta<Vehicle> motocycle)
{

}
}

When I send request:
PUT http://localhost:50232/Motorcycles HTTP/1.1
Host: localhost:50232
Content-Type: application/atom+xml
Content-Length: 796

<entry xml:base="http://localhost:50232/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<category term="ODataRepro.Motorcycle" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2012-09-24T20:28:44Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Name>Test</d:Name>
<d:Model m:type="Edm.Int32">0</d:Model>
<d:CanDoAWheelie m:type="Edm.Boolean">false</d:CanDoAWheelie>
</m:properties>
</content>
</entry>

It get 406 response.

Source code checked in, #fe17e7fcb5e2

$
0
0
Remove AttributeEdmPropertyConvention<TPropertyConfiguration, TAttribute> and AttributeEdmTypeConvention<TEdmTypeConfiguration,TAttribute> to avoid partial trust issues with querying on certain machines

Edited Issue: Delta doesn't work base type [451]

$
0
0
For example, I have controller class:
public class MotorcyclesController : ApiController
{
public void Put(Delta<Vehicle> motocycle)
{

}
}

When I send request:
PUT http://localhost:50232/Motorcycles HTTP/1.1
Host: localhost:50232
Content-Type: application/atom+xml
Content-Length: 796

<entry xml:base="http://localhost:50232/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<category term="ODataRepro.Motorcycle" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2012-09-24T20:28:44Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Name>Test</d:Name>
<d:Model m:type="Edm.Int32">0</d:Model>
<d:CanDoAWheelie m:type="Edm.Boolean">false</d:CanDoAWheelie>
</m:properties>
</content>
</entry>

It get 406 response.

Commented Issue: Delta doesn't work base type [451]

$
0
0
For example, I have controller class:
public class MotorcyclesController : ApiController
{
public void Put(Delta<Vehicle> motocycle)
{

}
}

When I send request:
PUT http://localhost:50232/Motorcycles HTTP/1.1
Host: localhost:50232
Content-Type: application/atom+xml
Content-Length: 796

<entry xml:base="http://localhost:50232/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<category term="ODataRepro.Motorcycle" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2012-09-24T20:28:44Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Name>Test</d:Name>
<d:Model m:type="Edm.Int32">0</d:Model>
<d:CanDoAWheelie m:type="Edm.Boolean">false</d:CanDoAWheelie>
</m:properties>
</content>
</entry>

It get 406 response.
Comments: We should add this support.

Edited Issue: Delta doesn't support abstract class [450]

$
0
0
As we are supporting abstract base type, we should make Delta<T> to support abstract as well.

Current definition of Delta<T> is:

public class Delta<TEntityType> : DynamicObject, IDelta<TEntityType>, IDelta where TEntityType : class, new()

Closed Issue: ODataMediaTypeFormatter can't deserialize derived type if base type is not in edm model [449]

$
0
0
For example, we have model class:
public abstract class Vehicle
{
[Key]
public int Model { get; set; }
[Key]
public string Name { get; set; }

public virtual int WheelCount { get; set; }
}

public class Motorcycle : Vehicle
{
public override int WheelCount { get { return 2; } }

public bool CanDoAWheelie { get; set; }
}

Build EDM model:
var motocycle = builder
.Entity<Motorcycle>();
motocycle.HasKey(v => v.Name)
.HasKey(v => v.Model)
.Property(v => v.WheelCount);
//.DerivesFrom<Vehicle>();
motocycle.Property(m => m.CanDoAWheelie);
motocycle.HasMany(m => m.Vehicles);
motocycle.HasMany(m => m.Motocycles);
motocycle.HasMany(m => m.SportBikes);

Define controller:
public class MotorcyclesController : ApiController
{
public void Post(Vehicle motocycle)
{
}
}

When posting back:
POST http://localhost:50232/Motorcycles HTTP/1.1
Host: localhost:50232
Content-Type: application/atom+xml
Content-Length: 796

<entry xml:base="http://localhost:50232/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
<category term="ODataRepro.Motorcycle" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<id />
<title />
<updated>2012-09-24T20:28:44Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Name>Test</d:Name>
<d:Model m:type="Edm.Int32">0</d:Model>
<d:CanDoAWheelie m:type="Edm.Boolean">false</d:CanDoAWheelie>
</m:properties>
</content>
</entry>

It reports error:

Microsoft.Data.OData.ODataException occurred
HResult=-2146233079
Message=An entry with type 'ODataRepro.Motorcycle' was found, but it is not assignable to the expected type 'ODataRepro.Vehicle'. The type specified in the entry must be equal to either the expected type or a derived type.
Source=Microsoft.Data.OData
StackTrace:
at Microsoft.Data.OData.ValidationUtils.ValidateEntityTypeIsAssignable(IEdmEntityTypeReference expectedEntityTypeReference, IEdmEntityTypeReference payloadEntityTypeReference)
InnerException:

Comments: You need to add the Vehicle to the model explicitly. In the conventional model builder, we can add the base class automatically.

Edited Issue: Support ComplexType inheritance in OData [448]

$
0
0
The current ODataModelBuilder only support to set base type for entity type. However, the OData spec says complex type can have base type, too.

"derived type: A type that is derived from the base type. Only complex type and entity type can define a base type."

Many people are requesting the same feature for WCF data service. http://data.uservoice.com/forums/72027-wcf-data-services-feature-suggestions/suggestions/2556935-support-type-inheritance-in-complex-types

Closed Issue: Compare int with enum in $filter will report can't compare int with string error [447]

$
0
0
For example: http://localhost:64513/api/Model?$filter=1+eq+Enum3

Response: HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcaG9uZ3llc1xhc3BuZXQtMTVkZmU3ZTA3NTlmXFNhbXBsZXNcTmV0NFxDU1xXZWJBcGlcT0RhdGFTZXJ2aWNlU2FtcGxlVlMxMVxRdWVyeWFibGVSZXByb1xhcGlcTW9kZWw=?=
X-Powered-By: ASP.NET
Date: Mon, 24 Sep 2012 06:43:40 GMT
Content-Length: 1932

{"Message":"The query specified in the URI is not valid.","ExceptionMessage":"A binary operator with incompatible types was detected. Found operand types 'Edm.Int32' and 'Edm.String' for operator kind 'Equal'.","ExceptionType":"Microsoft.Data.OData.ODataException","StackTrace":" at Microsoft.Data.OData.Query.MetadataBinder.BindBinaryOperator(BinaryOperatorQueryToken binaryOperatorToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.ProcessFilter(QueryNode query, QueryToken filter)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindTree(SyntacticTree syntax)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindQuery(SyntacticTree syntax)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model, Int32 maxDepth)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model)\r\n at System.Web.Http.OData.Query.FilterQueryOption.get_QueryNode() in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\FilterQueryOption.cs:line 68\r\n at System.Web.Http.OData.Query.FilterQueryOption.ApplyTo(IQueryable query, ODataQuerySettings querySettings, IAssembliesResolver assembliesResolver) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\FilterQueryOption.cs:line 123\r\n at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\ODataQueryOptions.cs:line 185\r\n at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\QueryableAttribute.cs:line 173"}
Comments: We model the enum as string type, so this is not supported.

Closed Issue: OrderBy Clauses Shade Programmed Ones [444]

$
0
0
The scenario is to return IQueryable as follows:

_dataContext
.Cards
.OrderByDescending(kc => kc.SendDate)
.Where(x => x.SendDate > someDate);

Framework inserts additional orderby clauses on the primary key to ensure a stable sort. The resulting query is as follows:

_dataContext
.Cards
.OrderByDescending(kc => kc.SendDate)
.Where(x => x.SendDate > someDate)
.Userqueries
.OrderBy(kc => kc.Id)

So, the first ordering is shaded.

Related discussion: http://aspnetwebstack.codeplex.com/discussions/391082 .
Comments: We have a knob to disable this already.

Edited Issue: Exceptions raised from IQueryable implementation are always propagated as HTTP 500 [442]

$
0
0
I have constructed a Web API controller with an IQueryable action method as follows.

public class ValuesController : ApiController
{
[Queryable]
IQueryable<int> GetValues()
{
Task<int>[] tasks =
{
Task.Factory.StartNew<int>(() =>
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
})
};

return tasks.Select(t => t.Result).AsQueryable();
}
}

Note that the GetValues() method is designed to raise an HttpResponseException when the Queryable action filter is run. It does not matter that the query values are computed asynchronously; I have also reproduced this by returning an IQueryable<int> implementation that raises the same exception for each property/method on the interface.

When this query is evaluated, a new exception with status code 500 (internal server error) is raised. Since I am explicitly raising and HttpResponseException via my query evaluation, I am expecting that the framework propagate my exception instead.

Edited Issue: QueryableAttribute doesn't support query on public field [441]

$
0
0
To repro:

public class Movie
{
public string Name = null;
}

public class MoviesController : ApiController
{
[Queryable]
public IEnumerable<Movie> Get()
{
return new Movie[] {
new Movie {
Name = "Test"
}
}
}
}

Send request: http://localhost/api/Movies?filter=Name eq null

Response:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcaG9uZ3llc1xkb2N1bWVudHNcdmlzdWFsIHN0dWRpbyAyMDEyXFByb2plY3RzXE12Y0FwcGxpY2F0aW9uMlxNdmNBcHBsaWNhdGlvbjJcYXBpXE1vdmllcw==?=
X-Powered-By: ASP.NET
Date: Fri, 21 Sep 2012 18:30:50 GMT
Content-Length: 2070

{"$id":"1","Message":"The query specified in the URI is not valid.","ExceptionMessage":"Type 'MvcApplication2.Models.Movie' does not have a property 'Field'.","ExceptionType":"Microsoft.Data.OData.ODataException","StackTrace":" at Microsoft.Data.OData.Query.MetadataBinder.BindPropertyAccess(PropertyAccessQueryToken propertyAccessToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindBinaryOperator(BinaryOperatorQueryToken binaryOperatorToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.ProcessFilter(QueryNode query, QueryToken filter)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindTree(SyntacticTree syntax)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindQuery(SyntacticTree syntax)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model, Int32 maxDepth)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model)\r\n at System.Web.Http.OData.Query.FilterQueryOption.get_QueryNode() in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\FilterQueryOption.cs:line 68\r\n at System.Web.Http.OData.Query.FilterQueryOption.ApplyTo(IQueryable query, ODataQuerySettings querySettings, IAssembliesResolver assembliesResolver) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\FilterQueryOption.cs:line 123\r\n at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\ODataQueryOptions.cs:line 185\r\n at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\QueryableAttribute.cs:line 173"}

Commented Issue: QueryableAttribute doesn't support query on public field [441]

$
0
0
To repro:

public class Movie
{
public string Name = null;
}

public class MoviesController : ApiController
{
[Queryable]
public IEnumerable<Movie> Get()
{
return new Movie[] {
new Movie {
Name = "Test"
}
}
}
}

Send request: http://localhost/api/Movies?filter=Name eq null

Response:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?YzpcdXNlcnNcaG9uZ3llc1xkb2N1bWVudHNcdmlzdWFsIHN0dWRpbyAyMDEyXFByb2plY3RzXE12Y0FwcGxpY2F0aW9uMlxNdmNBcHBsaWNhdGlvbjJcYXBpXE1vdmllcw==?=
X-Powered-By: ASP.NET
Date: Fri, 21 Sep 2012 18:30:50 GMT
Content-Length: 2070

{"$id":"1","Message":"The query specified in the URI is not valid.","ExceptionMessage":"Type 'MvcApplication2.Models.Movie' does not have a property 'Field'.","ExceptionType":"Microsoft.Data.OData.ODataException","StackTrace":" at Microsoft.Data.OData.Query.MetadataBinder.BindPropertyAccess(PropertyAccessQueryToken propertyAccessToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindBinaryOperator(BinaryOperatorQueryToken binaryOperatorToken)\r\n at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n at Microsoft.Data.OData.Query.MetadataBinder.ProcessFilter(QueryNode query, QueryToken filter)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindTree(SyntacticTree syntax)\r\n at Microsoft.Data.OData.Query.MetadataBinder.BindQuery(SyntacticTree syntax)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model, Int32 maxDepth)\r\n at Microsoft.Data.OData.Query.SemanticTree.ParseUri(Uri queryUri, Uri serviceBaseUri, IEdmModel model)\r\n at System.Web.Http.OData.Query.FilterQueryOption.get_QueryNode() in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\FilterQueryOption.cs:line 68\r\n at System.Web.Http.OData.Query.FilterQueryOption.ApplyTo(IQueryable query, ODataQuerySettings querySettings, IAssembliesResolver assembliesResolver) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\FilterQueryOption.cs:line 123\r\n at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\OData\\Query\\ODataQueryOptions.cs:line 185\r\n at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext) in C:\\dd\\DevDiv\\Offcycle\\WPT\\WebStackRuntime\\runtime\\src\\System.Web.Http.OData\\QueryableAttribute.cs:line 173"}
Comments: We should support public fields in our conventional model builder by default, and customer can use IgnoreDataMember to opt out.

New Post: support for batch in odata

$
0
0

Thanks for the answer, I did look into that example right after I posted question here, however it seems a bit different. Have anyone tried adopting this for WCF Data Client?

Thanks.

Created Issue: Duplicate references to System.Web.WebPages.Administration.dll after installing Administration NuGet package on app that had been upgraded to version 2. [452]

$
0
0
1. In Visual Studio, create a new Razor v1 web site
2. Using the NuGet Package Manager, install the "Microsoft ASP.NET Web Pages" package to upgrade the site to version 2.
3. Note the changes made to /bin and web.config, and then install Microsoft ASP.NET Web Pages 2 Administration.

Result: The package adds a reference to System.Web.WebPages.Administration to web.config even if the latest version is already in the site's /bin folder. This will causes the assembly to effectively be loaded twice, causing untold woe if you try to run the site.
Expected: We ought to be smarter in the install script about whether we need to add a web.config reference to the assembly. In this case, because a version of the assembly already exists in /bin, I'd expect the package to only update that assembly.

New Post: Multiple Get[NavigationProperty] methods on controller

$
0
0
I feel incredibly stupid: Adding the action selector thing fixes my issues. Thanks for the hint! :)


On Mon, Sep 24, 2012 at 7:50 PM, Matthijs ter Woord <matthijsterwoord@gmail.com> wrote:

Thanks for your reaction. I think I miss something. (The action selector thing)
Will look into it tomorrow and reply back to you.


Edited Issue: Can't customize navigation link builder in ODataConventionModelBuilder [473]

$
0
0
For example, I want to change the navigation property link by providing my own link builder code:

public class Todo
{
public int Id { get; set; }
public Person CreatedBy { get; set; }
}
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}

var builder = new ODataConventionModelBuilder();
var todoes = builder.EntitySet<Todo>("Todo");
todoes.HasNavigationPropertiesLink(
todoes.EntityType.NavigationProperties,
(entityContext, navigationProperty) => new Uri(entityContext.UrlHelper.Link(ODataRouteNames.PropertyNavigation, new { Controller = "Todo", parentId = entityContext.EntityInstance.Id, NavigationProperty = navigationProperty.Name })));
return builder.GetEdmModel();

The code reports following error:

System.InvalidOperationException occurred
HResult=-2146233079
Message=No NavigationLink factory was found for the property 'CreatedBy' on entity set 'Todo'. Try calling HasNavigationPropertyLink on the EntitySetConfiguration.
Source=System.Web.Http.OData
StackTrace:
at System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildNavigationLink(EntityInstanceContext context, IEdmNavigationProperty navigationProperty) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntitySetLinkBuilderAnnotation.cs:line 121
InnerException:

Commented Issue: Can't customize navigation link builder in ODataConventionModelBuilder [473]

$
0
0
For example, I want to change the navigation property link by providing my own link builder code:

public class Todo
{
public int Id { get; set; }
public Person CreatedBy { get; set; }
}
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}

var builder = new ODataConventionModelBuilder();
var todoes = builder.EntitySet<Todo>("Todo");
todoes.HasNavigationPropertiesLink(
todoes.EntityType.NavigationProperties,
(entityContext, navigationProperty) => new Uri(entityContext.UrlHelper.Link(ODataRouteNames.PropertyNavigation, new { Controller = "Todo", parentId = entityContext.EntityInstance.Id, NavigationProperty = navigationProperty.Name })));
return builder.GetEdmModel();

The code reports following error:

System.InvalidOperationException occurred
HResult=-2146233079
Message=No NavigationLink factory was found for the property 'CreatedBy' on entity set 'Todo'. Try calling HasNavigationPropertyLink on the EntitySetConfiguration.
Source=System.Web.Http.OData
StackTrace:
at System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildNavigationLink(EntityInstanceContext context, IEdmNavigationProperty navigationProperty) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntitySetLinkBuilderAnnotation.cs:line 121
InnerException:

Comments: Introduce an extensibility point to allow user to modify the model before finally building the model.

Edited Issue: Can't set navigation property as required when using ODataConventionModelBuilder [472]

$
0
0
For example, I want to set one of the navigation property to be required:
public class Todo
{
public int Id { get; set; }
public Person CreatedBy { get; set; }
}
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}

var builder = new ODataConventionModelBuilder();
var todoes = builder.EntitySet<Todo>("Todo");
todoes.EntityType.HasRequired(t => t.CreatedBy);
return builder.GetEdmModel();

However, it reports following error:

System.ArgumentException occurred
HResult=-2147024809
Message=The multiplicity of the 'CreatedBy' property must be 'ZeroOrOne'.
Parameter name: navigationProperty
Source=System.Web.Http.OData
ParamName=navigationProperty
StackTrace:
at System.Web.Http.OData.Builder.EntityTypeConfiguration.AddNavigationProperty(PropertyInfo navigationProperty, EdmMultiplicity multiplicity) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntityTypeConfiguration.cs:line 226
InnerException:

Commented Issue: Can't set navigation property as required when using ODataConventionModelBuilder [472]

$
0
0
For example, I want to set one of the navigation property to be required:
public class Todo
{
public int Id { get; set; }
public Person CreatedBy { get; set; }
}
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
}

var builder = new ODataConventionModelBuilder();
var todoes = builder.EntitySet<Todo>("Todo");
todoes.EntityType.HasRequired(t => t.CreatedBy);
return builder.GetEdmModel();

However, it reports following error:

System.ArgumentException occurred
HResult=-2147024809
Message=The multiplicity of the 'CreatedBy' property must be 'ZeroOrOne'.
Parameter name: navigationProperty
Source=System.Web.Http.OData
ParamName=navigationProperty
StackTrace:
at System.Web.Http.OData.Builder.EntityTypeConfiguration.AddNavigationProperty(PropertyInfo navigationProperty, EdmMultiplicity multiplicity) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntityTypeConfiguration.cs:line 226
InnerException:

Comments: We should honor the HasRequired setting from user.
Viewing all 7925 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>