none
Custom property added to Entity class doesn't show in "Data Sources" RRS feed

  • Question

  • I want to add a read-only property "FullName" to my Linq-to-SQL entity class, so I can bind the FullName property to a grid.

    This is what I have added to my code file:

    namespace MyEntityNamespace
    {
    public partial class MyEntity
    {
    public string FullName
    {
    get { return FirstName + " " + LastName; }
    }
    }
    }


    I can access the FullName property through code, but when I add the MyEntity object as an object data source in the "Data Sources" window, FullName does not show. This stops me from databinding to it.

    If I take the designer generated code for the MyEntity class and paste it into my .cs file, the FullName property will show!

    Any ideas?
    Thursday, April 10, 2008 3:56 PM

Answers

  • To answer my own question:

    The solution is to do this:

    1. Quit VS
    2. Delete all the files in the obj\Debug\TempPE folder - there seems to be one DLL file per class referenced as a datasource.
    3. Restart VS


    Another bug to be fixed for SP1 ???
    Thursday, April 10, 2008 8:14 PM

All replies

  • I have managed to get some of my objects to work; and I have noticed a difference in the ".datasource" file:

    Objects that don't work have a .datasource file like:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
        This file is automatically generated by Visual Studio .Net. It is
        used to store generic object data source configuration information. 
        Renaming the file extension or editing the content of this file may  
        cause the file to be unrecognizable by the program.
    -->
    <GenericObjectDataSource DisplayName="Expertise" Version="1.0" xmlns="urnTongue Tiedchemas-microsoft-com:xml-msdatasource">
       <TypeInfo>AR.CVN2.DataContext.ExpertiseMaintenance.Expertise, DataContext.ExpertiseMaintenanceDataContext.designer.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
    </GenericObjectDataSource>


    Objects that do work look like this:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
        This file is automatically generated by Visual Studio .Net. It is
        used to store generic object data source configuration information. 
        Renaming the file extension or editing the content of this file may  
        cause the file to be unrecognizable by the program.
    -->
    <GenericObjectDataSource DisplayName="ValuerBranch" Version="1.0" xmlns="urnTongue Tiedchemas-microsoft-com:xml-msdatasource">
       <TypeInfo>AR.CVN2.DataContext.ValuerEdit.ValuerBranch, CVN2Client, Version=0.9.1.21060, Culture=neutral, PublicKeyToken=null</TypeInfo>
    </GenericObjectDataSource>



    So I think the <TypeInfo> element generated needs to point to the generated type rather than the .designer.cs file (because .designer.cs only has part of the class in it - hence why my FullName is missing)


    Thursday, April 10, 2008 4:52 PM
  • To answer my own question:

    The solution is to do this:

    1. Quit VS
    2. Delete all the files in the obj\Debug\TempPE folder - there seems to be one DLL file per class referenced as a datasource.
    3. Restart VS


    Another bug to be fixed for SP1 ???
    Thursday, April 10, 2008 8:14 PM