locked
Entities lost when using Linq to SQL across different projects RRS feed

  • Question

  • When I attempt to query or perform operations on entities queried from a Prism module project to a web application project in the same solution the entity count is always zero even though because it's data bound the controls do poulate with data.  Is this a known issue or am I doing something wrong?

    Wednesday, August 31, 2011 5:46 PM

Answers

  • On 8/31/2011 3:58 PM, drowblade wrote:
    > Can you explain? I achieved a workaroung using a WCF Service and Linq to
    > SQL but I'd like to do it using Linq to Entities. I am using Linq to
    > Entities and Entity Framework. Can you give me a pointer to put me on
    > track as to where and what I should search for to resolve it.
     You know the key here is to make your solution as loosely coupled as
    possible so that it doesn't matter if Linq-2-SQL or Entity Framework is
    being used within the solution. They should be interchangeable to some
    degree where either one of the technologies can be easily used without
    breaking the entire application if things change.
     
    You achieve this loose coupling by using a Data Transfer Object or DTO.
    It's an abstraction away from the ORM solution.
     
     
    It's about architecting the solution out the gate to achieve loose
    coupling.
     
    The Dofactory E-Commerce solutions all use the  same backend of WCF,
    BLL, DAL and Model. The model is interchangeable between Lin2-2-SQL and
    Entity Framework. All you have to do is get the source code, run it in
    debug mode, step through the code and see what is happening. You'll see
    the DTO(s) come into play.
     
    The clients are all interchangeable too. The client could be a Windows
    service making calls to the back-end or a Console application, because
    of the loose coupling and not just some user interface client.
     
    This is the best advise I can give you. You'll see what is happening in
    one shot instead of trying to piece-mill it together blow by blow.
     
     
    Really you are trying to achieve the below, but you are putting effort
    into the service layer, BLL and DAL so that they are interchangeable
    with any type of client application consuming the service.
     
     
    • Marked as answer by Bifrost Design Thursday, September 1, 2011 11:03 AM
    Wednesday, August 31, 2011 9:18 PM

All replies

  • On 8/31/2011 1:46 PM, drowblade wrote:
    > When I attempt to query or perform operations on entities queried from a
    > Prism module project to a web application project in the same solution
    > the entity count is always zero even though because it's data bound the
    > controls do poulate with data. Is this a known issue or am I doing
    > something wrong?
    >
     
    This is not a Linq-2-SQL forum. Maybe you have your terminology mixed up
    and you are rally talking about a Entity Framework issue.
     
    Wednesday, August 31, 2011 7:39 PM
  • Can you explain? I achieved a workaroung using a WCF Service and Linq to SQL but I'd like to do it using Linq to Entities. I am using Linq to Entities and Entity Framework. Can you give me a pointer to put me on track as to where and what I should search for to resolve it.
    Wednesday, August 31, 2011 7:58 PM
  • On 8/31/2011 3:58 PM, drowblade wrote:
    > Can you explain? I achieved a workaroung using a WCF Service and Linq to
    > SQL but I'd like to do it using Linq to Entities. I am using Linq to
    > Entities and Entity Framework. Can you give me a pointer to put me on
    > track as to where and what I should search for to resolve it.
     You know the key here is to make your solution as loosely coupled as
    possible so that it doesn't matter if Linq-2-SQL or Entity Framework is
    being used within the solution. They should be interchangeable to some
    degree where either one of the technologies can be easily used without
    breaking the entire application if things change.
     
    You achieve this loose coupling by using a Data Transfer Object or DTO.
    It's an abstraction away from the ORM solution.
     
     
    It's about architecting the solution out the gate to achieve loose
    coupling.
     
    The Dofactory E-Commerce solutions all use the  same backend of WCF,
    BLL, DAL and Model. The model is interchangeable between Lin2-2-SQL and
    Entity Framework. All you have to do is get the source code, run it in
    debug mode, step through the code and see what is happening. You'll see
    the DTO(s) come into play.
     
    The clients are all interchangeable too. The client could be a Windows
    service making calls to the back-end or a Console application, because
    of the loose coupling and not just some user interface client.
     
    This is the best advise I can give you. You'll see what is happening in
    one shot instead of trying to piece-mill it together blow by blow.
     
     
    Really you are trying to achieve the below, but you are putting effort
    into the service layer, BLL and DAL so that they are interchangeable
    with any type of client application consuming the service.
     
     
    • Marked as answer by Bifrost Design Thursday, September 1, 2011 11:03 AM
    Wednesday, August 31, 2011 9:18 PM
  • You're right, my bad. I am being confusing with my terminology. What I'm trying to do is use WCF RIA Services and Linq to Entities. Data binding works fine, but using C# to just get a count or operations revealed that no Entities were being returned.  Invoke operations didn't achieve anything either. I did a workaround using a WCF Service and Linq to Entities. Thanks for the articles, I'll look into it more.
    Thursday, September 1, 2011 11:08 AM