i use GUI tool of vs2008 to generate some LINQ to SQL class, my problem is Stri开发者_JAVA百科ngTemplate can not reach attributes of those model
$persons:{
<li>$it.name$</li>
}$
it printed:
<li></li>
<li></li>
<li></li>
name is public property of Person model. If i create a person class by myself, and the same attributes, StringTemplate can get it.
The designer produces a normal class with respect to the compiler, the code is simply autogenerated. I suspect that you have some other issue going on -- perhaps you haven't included the correct references/namespaces or you have a namespace conflict and it's picking the wrong class.
This is not the correct solution, but I am having the same trouble, and using $it._name$
works for me. This is accessing the private backing field though, so is not a good idea. Still, it means that StringTemplate can find that field, but not the name
property to go with it. Odd.
Edit:
Got it. StringTemplate assumes that properties start with an uppercase letter. so if your property was called Name
it would work. You could rename your properties or fix the offending bit of code in StringTemplate's source at
ASTExpr.cs:RawGetObjectProperty
around the call to GetPropertyValueByName
(it uses methodSuffix
, not propertyName
).
精彩评论