Comments (11)
can you provide a pull request or a failing unit test?
Eric Hexter
blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexter
On Tue, Dec 11, 2012 at 4:32 AM, srnux [email protected] wrote:
Model pseudo-code:
[Key]
public long AnythingDifferentFromId { get; set; }Breaks at line 49, ViewHelperExtensions.cs :
return
model.GetType().GetProperty(model.IdentifierPropertyName()).GetValue(model,new
object[0]);
with exception:
Object reference not set to an instance of an object.Cause, line ~60:
if (type.GetProperties().Any(info => info.PropertyType.AttributeExists()))
does not find the KeyPossible solution, replace the if inside IdentifierPropertyName with:
if (type.GetProperties().Any(info =>
info.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute),
true)!=null))
{
return
type.GetProperties().First(info =>
info.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute),
true)!=null).Name;
}—
Reply to this email directly or view it on GitHubhttps://github.com//issues/32.
from twitter.bootstrap.mvc.
I will try to provide the unit test as soon I get to my development machine.
Thanks,
Luka
2012/12/22 Eric Hexter [email protected]
can you provide a pull request or a failing unit test?
Eric Hexter
blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexterOn Tue, Dec 11, 2012 at 4:32 AM, srnux [email protected] wrote:
Model pseudo-code:
[Key]
public long AnythingDifferentFromId { get; set; }Breaks at line 49, ViewHelperExtensions.cs :
returnmodel.GetType().GetProperty(model.IdentifierPropertyName()).GetValue(model,new
object[0]);
with exception:
Object reference not set to an instance of an object.Cause, line ~60:
if (type.GetProperties().Any(info =>
info.PropertyType.AttributeExists()))
does not find the KeyPossible solution, replace the if inside IdentifierPropertyName with:
if (type.GetProperties().Any(info =>info.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute),
true)!=null))
{
return
type.GetProperties().First(info =>info.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute),
true)!=null).Name;
}—
Reply to this email directly or view it on GitHub<
https://github.com/erichexter/twitter.bootstrap.mvc/issues/32>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-11640702.
from twitter.bootstrap.mvc.
Please find the unit tests inside a test project here:
https://github.com/srnux/MVCTwitterBootstrap
Luka
from twitter.bootstrap.mvc.
awesome.. i will add a project and unit tests in the for this extension
code and add the appropriate code to support the key attribute
Eric Hexter
blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexter
On Mon, Dec 24, 2012 at 5:15 AM, srnux [email protected] wrote:
Please find the unit tests inside a test project here:
https://github.com/srnux/MVCTwitterBootstrap
Luka
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-11658895.
from twitter.bootstrap.mvc.
I have another resolution (more like a quickfix) for this bug: change ... info.PropertyType.AttributeExists ... to info.AttributeExists ... on lines 66 and 70.
The problem is that info.PropertyType points to the type of the property (ie String) so it can't have the KeyAttribute. but info.AttributeExists asks about the attributes of the actual property.
from twitter.bootstrap.mvc.
@xkobram 's post should fix the issue.
from twitter.bootstrap.mvc.
Just to confirm I had the problem with a key attribute on a string, xkobram's solution fixed it.
from twitter.bootstrap.mvc.
Im having the same problem described but in muy situtation we are using fluent api so we do not add the key data annotation in the class or the ID to the key in the object. What can i do ?
I would appreciate any help.
from twitter.bootstrap.mvc.
You can change that method to find your id field by your convention.
On Saturday, July 20, 2013, eljeanc wrote:
Im having the same problem described but in muy situtation we are using
fluent api so we do not add the key data annotation in the class or the ID
to the key in the object. What can i do ?I would appreciate any help.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-21297540
.
Eric Hexter
blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexter
from twitter.bootstrap.mvc.
any idea on how to achieve this i have been thinking how to make it work without using the data annotations, this because our project will not use it directly in de dtos.
from twitter.bootstrap.mvc.
If you name your properties Id or key or some other predictable way you
can do it that way, the views support the name id now. That is how I use it
On Saturday, July 20, 2013, eljeanc wrote:
any idea on how to achieve this i have been thinking how to make it work
without using the data annotations, this because our project will not use
it directly in de dtos.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-21297958
.
Eric Hexter
blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexter
from twitter.bootstrap.mvc.
Related Issues (20)
- Error when trying to NUGET install HOT 9
- Bug in NavigationRouteConfigurationExtensions HOT 1
- Model editor does not display Start Date HOT 6
- adding additional attributes to "EditorFor" control HOT 2
- A namespace cannot directly contain members such as fields or methods HOT 7
- Paging issue with active page HOT 6
- End-to-end test: the generated solution does not compile HOT 1
- Support `[Display(Autogenerate=false)]`: decorated properties should not be displayed HOT 1
- htmlAttributes not forwarded
- BeginControlGroupFor doesn't always identify property names from an expression
- Controller alert methods should be extension methods rather than BootstrapBaseController HOT 3
- BootstrapBaseController can't handle multiple alerts HOT 2
- Support for ScaffoldColumn Attribute HOT 2
- Adding Glimpse nuget package breaks navigation extension HOT 6
- Do not use a custom unobrusive validation script HOT 1
- NavigationViewExtensions does not properly add active css class to active nav list item
- Custom text in TwitterBootstrapMVC.Renderers.Renderer.RenderValidationSummary() HOT 1
- Pulls Bootstrap V3 HOT 10
- Update to use twitter.bootstrap 3 HOT 5
- Twitter Bootstrap for ASP.Net MVC 4 Sample 1.1.100 Crash HOT 35
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitter.bootstrap.mvc.