Property in partial class is not visible in project binding sources !
Well I'm new to ADO.NET Entity Framework and I don't know how to do this:
I have a single database table called "POSUser" and i want to use it with Entity Framework, so I've use the Visual Studio to
generate the mapings and the related classes in the Designer.cs using the designer tool. Then I've setup a form, a grid and a binding source connected to the POSUser class (object binding). It seams to work fine, the POSUser datasource shows all the properties.
The next step it will be customising this generated class by adding new property :
public partial class POSUsers
{
public bool CanPerformDiscounts
{
get
{
return true;
}
}
.................................
Everything builds nicely, I can use this property in code and in linq query.
The problem is that I can't see this new added property on my grid. The project datasource dosen't show it.
How can I make this property show in my object binding source and grid ?
All Replies
I added your CanPerformDiscounts partial property to one of my entity classes, and I was able to get it to show up in both the project data source for the entity as well as in the bound datagridview. Did you refresh the project data source after you added the new partial property? Also, is it possible that you are using a pre-release version of Visual Studio 2008 SP1? There were some changes made to data binding right before the final release.
Best wishes,
Glenn Gailey [MSFT]
HI
I had this problem when i was using vs2008 beta , but it is not a problem if after building project you can not find your custom property in the datasource , if you add a column to the grid and set its DataPropertyName with your Property(CanPerformDiscounts) it will work nicely
.- Hi, firstly thanks for taking your time to answer my question
I'm using this product version:
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: Professional
Microsoft Visual Basic 2008 91605-031-5000002-60737
Microsoft Visual Basic 2008
Microsoft Visual C# 2008 91605-031-5000002-60737
Microsoft Visual C# 2008
Microsoft Visual Studio 2008 Tools for Office 91605-031-5000002-60737
Microsoft Visual Studio 2008 Tools for Office
Microsoft Visual Web Developer 2008 91605-031-5000002-60737
Microsoft Visual Web Developer 2008
Crystal Reports AAJ60-G0MSA4K-68000CF
Crystal Reports Basic for Visual Studio 2008 - Hi, I have the same product version and the same problem. Was a solution ever found for this?
Ean - I have the same problem and i guess it has something to do with datasource description file it has filename.cs in typeinfo
<TypeInfo>BindingTest.MyEntityType, MyObjectLayer.Designer.cs,
and my extension properties are as you can gues in other file.. - I have found a solution:
Remove your bugged Data Source from project, exclude generated EDMX from project, add new Data Source select your desired type (you should have it couse you still have partial class with you modification) and finish, then add EDMX back and you will have you properties in data source.
Note: that producing this steps will change you *.datasource description file for example if you had:
<TypeInfo>BindingTest.MyEntityType, MyObjectLayer.Designer.cs, ... bla bla bla it will no longer contain *.cs file it will be replaced with NameSpace like this
<TypeInfo>BindingTest.MyEntityType, BindingTest, ... bla bla bla
But if you edit this file and change this by yourself this will not work i don't know why maybe there is some kind of cache or smt.- Proposed As Answer byBroken Pipe Sunday, May 10, 2009 6:20 PM
- Bug report:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=446843 - Well Broken Pipe, though it's long in coming, I want to thank you for your solution to this problem. I gave up on it but found myself faced with it again and your workaround worked wonderfully. Happy coding.
Ean


