Questions tagged [partial-classes]

With this keyword classes can be split into multiple definitions, but it compiles into one class.

With this keyword, classes can be split into multiple (mostly two) definitions, but the code compiles into one run-time class.

References

441 questions
3
votes
2 answers

Using a part of a class in multiple projects

I have a set of methods that do some utility work over SQL connection, and until now these have been copied over from project to project. But as time goes on, project numbers have grown and I need to keep these methods in sync in case I find a bug…
Axarydax
  • 16,353
  • 21
  • 92
  • 151
3
votes
1 answer

Properties in partial class not appearing in Data Sources window!

Entity Framework has created the required partial classes. I can add these partial classes to the Data Sources window and the properties display as expected. However, if I extend any of the classes in a separate source file these properties do not…
Tim Murphy
  • 4,892
  • 4
  • 40
  • 48
3
votes
1 answer

Extending an entity framework 6 class

I have the class generated by Entity Framework called Person.cs which is in namespace Project.Model. I have then put a new folder in the project called Extensions, added Person.cs inside there and set the namespace for this file to…
dynamicuser
  • 1,522
  • 3
  • 24
  • 52
3
votes
5 answers

Partial classes/partial methods vs base/inherited classes

a question about class design. Currently I have the following structure: abstract Base Repository Class Default Repository implementation class (implements some abstract methods, where logic is common thru all of the Specific classes but leaves…
mare
  • 13,033
  • 24
  • 102
  • 191
3
votes
3 answers

Partial Classes and Data Access Code

I have a lot of classes for data-access in one of my projects, but these classes are becoming extremely bulky because of the code that retrieves the data from the data readers. My code generally looks like this: // Execute the data reader using…
Dan Scott
  • 139
  • 1
  • 9
3
votes
2 answers

How to use a partial class to set an associations child property to false

I have a database that is changing a lot and i am constantly having to go into the data context designer and manually set a number of associations child properties to false. Each time i delete the table from the designer i have to go back in and…
ps_md
  • 209
  • 2
  • 10
3
votes
2 answers

How to add an Initializer List constructor to STL vector

So what I want to do is extend the existing vector class in my program to allow me to say this, vector* vec = new vector(){"Value1","Value2"}; or vector* vec = new vector({"Value1","Value2"}); or vector vec…
Dan
  • 2,625
  • 7
  • 39
  • 52
3
votes
4 answers

Create partial class for referenced assembly

Possible Duplicate: Is it possible to declare a partial class in two projects Say In my project solution, I have two project, ProjectA and ProjectB. ProjectA created: MyClassA Then ProjectB has ProjectA referenced. Is it possible to create a…
King Chan
  • 4,212
  • 10
  • 46
  • 78
3
votes
3 answers

Conversion Class Extensiblity (Extension Methods vs Parital Class)

I am creating a conversion class for frequency, and I wanted to allow my team to be able to add additional conversions when they are needed. Frequency myFrequency = new Frequency(100, MHz); double value = myFrequency.InKhz(); The source code for…
Robin Robinson
  • 1,595
  • 1
  • 20
  • 24
3
votes
3 answers

Is using partial classes instead of Facade pattern an anti-pattern itself?

A few years ago, I was told to implement the business logic code in separated .cs files, although this files wrapped the same partial class. So one could call a method from business layer like this: using(FooPartialDisposableClass…
Painy James
  • 805
  • 2
  • 13
  • 26
3
votes
1 answer

Implementing linqtosql partial DataContext class - how to inspect before/after values

I'm trying to extend the linqtosql classes generated by the VS designer and need to determine if the value of a specific field has changed. Is there a way for me to access the before and after values for a field in the DataContext Update method for…
joshb
  • 5,182
  • 4
  • 41
  • 55
2
votes
3 answers

How do I find the matching partial-class in C# & Visual Studio 2010 in a XAML file?

I have an app created with a third-party MVVM framework. I have a bunch of Views that will be essentially the same, so I want to inject a custom class in between my Views and the original framework View base as a new base. But when I do so I get the…
IAmAN00B
  • 1,913
  • 6
  • 27
  • 38
2
votes
3 answers

Partial class constructors and event handler registration

I need to register an Event Handler for a class which is generated by a Template - the T4 Template within the EntityFramework. Currently, we have edited the generated code to register the handler within the Constructor of the generated class (the…
JTech
  • 3,420
  • 7
  • 44
  • 51
2
votes
2 answers

Can partial class access static methods in C#?

The tutorial application, MusicStore -MVC3 (92 PageNo), created a POCO class like: public partial class ShoppingCart { MusicStoreEntities storeDB = new MusicStoreEntities(); public static ShoppingCart GetCart(HttpContextBase…
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83
2
votes
1 answer

Entity Framework Custom Property using external Parameters

I have an EDM used to bring back a collection of "Product" entities within a DAL project. An MVC website project references and directly instantiates the ObjectContext and returns an IQueryable to the website for paging and displaying of Products.…
MagicalArmchair
  • 911
  • 1
  • 12
  • 26