1

I have a question about partial classes in c# enter image description here

In This picture, I have a domain model. I am have added reference this(DomainModelLib) to Client application and repoistory application.

Repository application is using this domain model classes as "DbSet" and getting data from database. Realtions are created in model partial classes as you can see.

I referenced Model to Client application. I wanna first partial(first red frame) of Product class can access in Client application but second part(bottom red frame) of class can not access.

But two parts should be accesible in repository. Is this possible?

(NHibernate XML mapping is keeping relations from users, I wana keep somethings from users this way in Entity Framework)

bayramucuncu
  • 1,014
  • 10
  • 20

2 Answers2

0

Accessibility isn't in any way defined by which source file contributes to a partial class.

The only way I can see of doing this exactly as stated is to make the members declared in the bottom red frame internal, and use [InternalsVisibleTo] to allow the EFRepository project access to internal members in DomainModelLib.

You might want to consider alternatives though... it's hard to suggest good alternatives without knowing exactly what you're trying to achieve, but giving two different "external" libraries different accessibility is fundamentally tricky.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I wanna separate objects two part as clients can access, and repository can access. For example users do not need to see SizeId in Products. – bayramucuncu Jun 05 '13 at 12:52
  • NHibernate XML mapping is keeping relations from users, I wana keep somethings from users this way in Entity Framework – bayramucuncu Jun 05 '13 at 12:59
0

A new library could be created (say X). Move the bottom red frame into that. Reference X from both domain and repo.

aquaraga
  • 4,138
  • 23
  • 29