Dave Gahan
Dave Gahan

Reputation: 299

Visual Studio solution - issue with referenced projects and object accesibility

this might be a bit dummy question but I'm confused... I have a simple C# solution in VS with 3 projects

Now, I've added 'DAL' as a reference inside 'CORE' so now I can see and use my DB methods. However, since I want to send one of the 'CORE' classes to my INSERT method which is inside 'DAL' (to insert the full object) I cannot see or access it, and I also can't add a circular reference and add 'CORE' to 'DAL'.

public void InsertOrUpdateResultData(MyObject _obj)

MyObject is from 'CORE' project.

Any help is appreciated.

Thanks

Upvotes: 1

Views: 51

Answers (3)

dvsoukup
dvsoukup

Reputation: 1596

If you're using the same class across multiple projects, as is your case here.. have you thought about using a shared project? You can add the shared project to all other projects you need. Based on what you've stated, it would probably be a better solution.

http://dailydotnettips.com/2015/07/28/using-shared-project-across-multiple-applications-in-visual-studio-2015/

Upvotes: 0

Konrad Lalik
Konrad Lalik

Reputation: 636

If you encounter such situation you are probably doing something wrong. I would suggest to rethink structure of your solution. Maybe it would be worth to create another library that can be included in both CORE and DAL projects.

Upvotes: 0

meJustAndrew
meJustAndrew

Reputation: 6613

You can extract the common classes inside a separate project and reference it from the CORE and DAL. Eventually you can create DTOs.

Upvotes: 1

Related Questions