The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

esDataSource - HOWTO - Select entities inside current project

Last post 07-24-2008, 11:58 PM by rotep. 13 replies.
Sort Posts: Previous Next
  •  07-22-2008, 4:47 AM 10322

    esDataSource - HOWTO - Select entities inside current project

    Hi,

    i would like to setup a esDataSource so that it displays the entities in my current project. I tried pointing to the /bin/InspectionList.dll assembly (InspectionList is the name of the project) and it works because I can select the InspectionListCollection. However I cannot build / run the application because it cannot include the /bin/InspectionList.dll (file is in use, probably by Visual Studio itself)

    So how do I configure an esDataSource to contain Entities defined in class files in the same project? I ask this because the project only contains 1 ES class (+ query, collection etc.). I don't want to create a seperate class library for every project where this occurs.

     

    p.s. According to the example at http://www.entityspaces.net/blog/TheImprovedEntitySpacesEsDataSourceForASPNET.aspx, I should point to the following assembly in c:\windows\microsoft.net\......\App_Code.dll. However this is for .NET 2.0 projects. In 3.5 there is no App_Code folder/assembly.

     

  •  07-22-2008, 5:29 AM 10325 in reply to 10322

    Re: esDataSource - HOWTO - Select entities inside current project

    I restarted Visual Studio and this allows me to build and run the application. However I get a Object Reference Not Set error which as usual doesn't tell anything.

    Added: I can create an implementation for the _esSelect event. Where I create a new collection, call LoadAll() and then set it to e.Collection. However sorting doesn't work and it just doesn't feel right.

    In this scenario, when I edit the esDataSource properties, the reference to the assembly is gone, but the EntityName and fieldnames are preserved in the dialog.

    This is a new project for testing and it is really basic. I'll add my code to make sure:

    Code:
    <cc1:esDataSource ID="esDataSource1" runat="server" />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                DataKeyNames="SiNumber,PnmMain,PnmKey" DataSourceID="esDataSource1">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="SiNumber" HeaderText="SiNumber" ReadOnly="True" 
                        SortExpression="SiNumber" />
                    <asp:BoundField DataField="PnmMain" HeaderText="PnmMain" ReadOnly="True" 
                        SortExpression="PnmMain" />
                    <asp:BoundField DataField="PnmKey" HeaderText="PnmAutoKey" ReadOnly="True" 
                        SortExpression="PnmAutoKey" />
                    <asp:BoundField DataField="Pn" HeaderText="Pn" SortExpression="Pn" />
                    <asp:BoundField DataField="Description" HeaderText="Description" 
                        SortExpression="Description" />
                    <asp:BoundField DataField="InspectionType" HeaderText="InspectionType" 
                        SortExpression="InspectionType" />
                    <asp:BoundField DataField="InspectionNotes" HeaderText="InspectionNotes" 
                        SortExpression="InspectionNotes" />
                    <asp:BoundField DataField="Time" HeaderText="Time" SortExpression="Time" />
                    <asp:BoundField DataField="Serial" HeaderText="Serial" 
                        SortExpression="Serial" />
                    <asp:BoundField DataField="Qty" HeaderText="Qty" SortExpression="Qty" />
                    <asp:BoundField DataField="SbType" HeaderText="SbType" 
                        SortExpression="SbType" />
                </Columns>
            </asp:GridView>
    If i remove the esDataSource and bind the Grid in code (page_load), it just works:
    Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim dsInspList As New BLL.IntranetApuInspectionCollection
            dsInspList.LoadAll()
    
            GridView1.DataSource = dsInspList
            GridView1.DataBind()
        End Sub
  •  07-22-2008, 6:43 AM 10328 in reply to 10325

    Re: esDataSource - HOWTO - Select entities inside current project

    esDataSource is meant to work with actual instances of EntitySpaces objects. It cannot be used are you are discussing here.
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-22-2008, 10:54 AM 10334 in reply to 10328

    Re: esDataSource - HOWTO - Select entities inside current project

    I can't seem to follow. Maybe because you didn't follow because I explained it wrongly ;-)

    I have ONE project. In this project I use one generated class of one of my tables (IntranetApuInspection), so I have a /generated and a /custom folder inside the project (not in app_code, this doesn't exist in .NET 3.5)

    I add a esDataSource to my page and would like to use the IntranetApuInspectionCollection as a 'source' in the esDatasource wizard. I cannot select any assembly, because it's in the current project. If i select the assembly in the /bin/ folder (nameofproject.dll), then the project cannot compile anymore because the file stays in use...
     

  •  07-22-2008, 11:37 AM 10335 in reply to 10334

    Re: esDataSource - HOWTO - Select entities inside current project

    Ahh, I see, sorry. Normally the esDataSource comes up pre-populated with all the classes in your web project that inherit from our esEntityCollection class. You should see those when it first comes up? Assuming you have a reference to whatever assembly contains them you should see them. That used to be problem we had way back when (in which case, once setup you could save and then open your project and it would go away). But again, you should see your classes automatically.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-23-2008, 12:48 AM 10343 in reply to 10335

    Re: esDataSource - HOWTO - Select entities inside current project

    I do NOT see the classes from my current webproject. I have to select an assembly before any classes show up. Since I do not have any assembly file I cannot choose the classes...

    (as mentioned, there obviously is an assembly file in the /bin/ folder, but I cannot select this one because then the project won't build anymore)

  •  07-23-2008, 8:14 AM 10350 in reply to 10343

    Re: esDataSource - HOWTO - Select entities inside current project

    You're on 2008 right, do the top of your files say EntitySpaces 2008?
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-23-2008, 1:07 PM 10353 in reply to 10350

    Re: esDataSource - HOWTO - Select entities inside current project

    I'm not at work at the moment, so I am unable to check. But I have been using only ES 2008, so I don't see a way anything else could appear at the top...

    I think it has something to do with VS2008 or ES locking the file when you select it for the esDataSource wizard. (when you build, the assembly of the project is overwritten in the /bin folder). The problem is that I have to select an assembly, it would be nice if the classes which are in the same project would show up automatically..

     

  •  07-23-2008, 7:12 PM 10358 in reply to 10353

    Re: esDataSource - HOWTO - Select entities inside current project

    Okay, for everyone that I know the classes do show up automatically. We have not had this reported since our fix quite a while ago. What are you using for Development, VS2008, VS2005 or one of the express products, it could be that this is a vista issue?

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-24-2008, 12:27 AM 10361 in reply to 10358

    Re: esDataSource - HOWTO - Select entities inside current project

    Here at work I use Visual Studio 2008 standard on Windows XP. So it cannot be a Vista issue, but maybe a VS Standard issue? (while this should not be the case...)

  •  07-24-2008, 1:15 AM 10364 in reply to 10361

    Re: esDataSource - HOWTO - Select entities inside current project

    Mike,

    1. I created a new project
    2. Added references + class files
    3. Built the project before adding the datasource

    Now it works! :-)

  •  07-24-2008, 7:17 AM 10366 in reply to 10364

    Re: esDataSource - HOWTO - Select entities inside current project

    Excellent. I'm glad it's working for you.
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-24-2008, 8:48 PM 10374 in reply to 10334

    Re: esDataSource - HOWTO - Select entities inside current project

    ... (not in app_code, this doesn't exist in .NET 3.5)

     FYI
    app_code does exists in aspx.net 3.5.

    1. Right click on project in solution explorer
    2. select "Add ASP.NET Folder"
    3. select "App_Code"

    This will add the App_Code folder to the project
    Place your custom and generated folders in this.

    Gary

  •  07-24-2008, 11:58 PM 10375 in reply to 10374

    Re: esDataSource - HOWTO - Select entities inside current project

    My bad, I meant the App_Code folder is not present anymore in VS 2008. I'm used to working with .NET 2.0 in VS 2005 and .NET 3.5 in VS 2008 :-)

View as RSS news feed in XML