Databinding and References

Posts   
 
    
Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 02-Jun-2006 03:37:44   

I'm a newbe using VS2005 (VB), SQL Server, the current LLBLGEN Pro and Adapter. I could do with some help for two problems.

I have the following projects in my Solution (where PMIS.WIN is a WinForm project intended to use manager classes in PMIS.BL).

PMIS.DB PMIS.DALDBSpecific PMIS.DAL PMIS.BL (references PMIS.DAL, PMIS.DALDBSpecific, LLBLGen.Pro.ORMSupportClasses.NET20) PMIS.WIN (references PMIS.BL, PMIS.DAL, LLBLGen.Pro.ORMSupportClasses.NET20)

First, some difficulties in doing design time binding. I've got a WinForm containing a DataGridView, a BindingSource and an EntityCollection. Datasource of the DataGridView is set to the BindingSource, and the BindingSource to the EntityCollection. I only seem to be able to add unbound columns to the grid and that doesn't seem right. Where have I gone wrong, what am I missing?

Second: In my DivisionManager (PMIS.BL) I'm trying to read all the entities for Division as follows:

    Dim adapter As New DataAccessAdapter()
    Try
        Dim allDivisions As New EntityCollection(New DivisionEntityFactory())
        adapter.FetchEntityCollection(allDivisions, Nothing)
    Finally
        adapter.Dispose()
    End Try

When I access DivisionManager from frmDivision (PMIS.WIN), I get the following error:

Could not load file or assembly 'PMIS.DALDBSpecific, Version=1.0.2343.43076, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I'm totally stuck, though I've noticed that within DivisionManager, I can only specify Imports for PMIS.DAL.DatabaseSpecific rather than PMIS.DALDBSpecific.

Any comments whatsoever would be welcomed.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Jun-2006 07:11:45   

Could not load file or assembly 'PMIS.DALDBSpecific, Version=1.0.2343.43076, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I'm totally stuck, though I've noticed that within DivisionManager, I can only specify Imports for PMIS.DAL.DatabaseSpecific rather than PMIS.DALDBSpecific.

To Import a Namespace, you should first add its assembly to the references of the project.

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 02-Jun-2006 13:13:23   

To Import a Namespace, you should first add its assembly to the references of the project

This is why I'm puzzelled, I've checked and:

I have references from PMIS.WIN to PMIS.BL & PMIS.DAL & ORMSupport etc, plus references from PMIS.BL to PMIS.DAL & PMIS.DALDBSpecific. I also have references in PMIS.DAL to ORMSupport etc (don't think this was added automatically or by me - its been a long night).

I'm sure its a problem of references, but all bases seem to be covered.

Have just noticed something peculiar. In the PMIS.DAL project there is DatabaseGeneric as there should be, but there is also a 'shadow' set of entries for DatabaseSpecific (the icons are just outlines).

Whilst in the PMIS.DALDBSpecific project, the DatabaseSpecific entry is preceded by a 'shadow' set of entries for DatabaseGeneric.

If you have any suggestions I'm all ears, but I think I've somehow seriously screwed-up. confused

Have to think about how to restart this cry but any comments may help me avoid repeating my mistakes.

I still have an issue with how to bind to my DataGridView:

First, some difficulties in doing design time binding. I've got a WinForm containing a DataGridView, a BindingSource and an EntityCollection. Datasource of the DataGridView is set to the BindingSource, and the BindingSource to the EntityCollection. I only seem to be able to add unbound columns to the grid and that doesn't seem right. Where have I gone wrong, what am I missing?

Any suggestions anyone disappointed

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Jun-2006 15:47:24   

I'll try to explain it in a simple way.

Now when you use the adapter model to generate you code. 2 projects get generated.

1- YourNameSpace project (DBGeneric) 2- YourNameSpaceDBSpecific project (DBSpecific)

The first project (DBGeneric) automatically references the ORMSupport assembly (since this assembly contains all the parent classes from which the generated classes inherit)

And as a general rule, any project you will create later which uses the DBGeneric classes should also reference the ORMSupport assembly.

The second project (DBSpecific) automatically references the DQE assembly as well as the ORMSupport assembly.

Any project you will create that needs to use the objects of the DBSpecific assembly, like the DataAccessAdapter class, you will need to reference the DBSpecific assembly.

So I suppose if you have a BL project, then you most probably will reference the DBGeneric, DBSpecific & ORMSupport assemblies.

And if there is a Presentation layer, most probably you will need to reference the BL, DBGeneric & ORMSupport assemblies. That's if you are going to use the entitty classes in your presentation layer. If not then you will only have to reference the BL assembly.

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 02-Jun-2006 19:31:17   

Walaa,

Thanks for your explanation which confirmed my approach and gave me the confidence to recreate the Solution from scratch. Not sure what I did but my original Solution was screwed, now it's ok.

I'm also now able to set a factory for my EntityCollection without VS crashing, so my datagridview columns are all defined simple_smile

The only problem now is why Division data isn't showing up in the grid. What I've thrown together is this:

DivisionManager does this:

_Public Class DivisionManager Public Sub New() getDivisions() End Sub

Function getDivisions() As EntityCollection
    Dim adapter As New DataAccessAdapter()
    Try
        Dim allDivisions As New EntityCollection(New DivisionEntityFactory())
        adapter.FetchEntityCollection(allDivisions, Nothing)
        Return allDivisions
    Finally
        adapter.Dispose()
    End Try
End Function

End Class_

The Load event for frmDivision does this:

_ Dim Divisions As New DivisionManager BindingSource1.DataSource = Divisions_

I know that if I create a reference to DBSpecific from my WIN form project, and place the slightly amended code in the load event of frmDivision, I can see the data, but I can't see where I'm going wrong here. Any thoughts on this?

Thanks for your patience

Markiemac
User
Posts: 132
Joined: 25-Apr-2006
# Posted on: 03-Jun-2006 07:47:32   

Hi

After sleeping on it, I've realised that my question is really, how can I pass an LLBLGEN Pro EntityCollection from my Business Layer to my Presentation layer (PL), without creating a reference to DBSpecific from the PL.

What recommendations are there for passing LLBLGEN Pro EntityCollections from a BL to PL?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 03-Jun-2006 09:27:56   

EntityCollection is a class in the dbgeneric project, so you don't need a reference to the dbspecific project when you pass an entitycollection simple_smile

Frans Bouma | Lead developer LLBLGen Pro