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
4
votes
3 answers

Why does the Entity Framework generate entities as partial classes?

Other ORMs I've used, such as Torque, Propel or Doctrine, generate 2 classes for each entity: for example, BaseCustomer and Customer. Customer inherits from BaseCustomer, and you can override methods or add your own. But the Entity Framework…
4
votes
1 answer

How to add extra property to the class in c# during using EF

I would like to extend my class which was generated by EF from database. I tried to do it using partial class: public partial class Users { public bool IsOnline { get; set; } = false; } I would like to populate my list of Users from…
marmite
  • 113
  • 8
4
votes
4 answers

Business logic in Entity Framework POCOs using partial classes?

I have business logic that could either sit in a business logic/service layer or be added to new members of an extended domain class (EF T4 generated POCO) that exploits the partial class feature. So I could have: a) bool…
Mark Chidlow
  • 1,432
  • 2
  • 24
  • 43
4
votes
2 answers

Additional partial classes for a Form

We have a big Form class that we like to split into peaces using partial class approach That could be done by manually modifying a project file, and adding MainFormPN.vb entry Form
volody
  • 6,946
  • 3
  • 42
  • 54
4
votes
1 answer

How to use partial method in C# to extend existing implemetation

It would be great if this would work. Am I trying to implement my idea in the wrong way? I would like to use partial method, to be able to extend existing code, and simply plug in/out implementation of methods. Basically exactly what the reference…
DDan
  • 8,068
  • 5
  • 33
  • 52
4
votes
4 answers

What is the advantage of partial classes over inheritance?

C# has the concept of partial classes. One instance I've seen this used is in WSDLs. Visual Studio could contact a server to find a service, and automatically generate a partial class based on it. Visual Studios would then provide you with a blank…
David says Reinstate Monica
  • 19,209
  • 22
  • 79
  • 122
4
votes
2 answers

How to draw partial classes on a UML diagram?

I would like to know how to indicate in a UML Class Diagram that 2 classes are partial. For example: File 'ClassApart1.cs' partial class ClassA{ /* this class is used for constructors and methods */ } File 'ClassApart2.cs' partial class ClassA{ /*…
atomicBee
  • 79
  • 3
  • 8
4
votes
2 answers

Can't abstract replace partial?

The biggest argument I've seen so far for partial classes is in the case of auto-generated code. From a Java perspective, I don't see why this can't simply be done using abstract classes, can't the auto-generated code simply be an abstract class…
Morad
  • 734
  • 5
  • 14
4
votes
2 answers

Guidelines - extension methods vs partial class

We are debating at work the best way to define methods for an entity class - as extensions methods or using partial classes. The kind of methods we're talking about don't modify the state of the entity, they are purely "helper" methods that…
Ashby
  • 583
  • 9
  • 20
4
votes
1 answer

Adding new constructors to entity

I'm using EF4.3. It's my first project so I'm learning as I go along. There are instances where I need to implment additional constructors for entities. I create an additional partial class to do this, so entity Users, will have an associated class…
dotnetnoob
  • 10,783
  • 20
  • 57
  • 103
3
votes
2 answers

Partial classes lost through a webservice reference

I have a webservice project (old asmx technology) in which I have a class User. This class has a DateTime property that represents the birthdate of this user. Beside this class, I have another file with a partial class User. In this partial class, I…
Nick Thissen
  • 1,802
  • 4
  • 27
  • 38
3
votes
2 answers

Doxygen: Partial Classes not supported?

I'm attempting to use Doxygen to document my web project, which contains mostly C# user controls, each of which is a partial class that inherits from UserControl. Example [Serializable] public partial class Dashboard_Ctrls_Dashboard :…
JMD
  • 403
  • 3
  • 6
  • 17
3
votes
3 answers

Cross-DDL Extension of an Entityclass

What I want to archieve: Service assembly (project) that holds EntityClasses - pure Data. GUI assembly that extends those Entities for its own pourposes - Runtime information for GUI. What I tried: Derivation (Gui defines class ExtendedEntity :…
Steav
  • 1,478
  • 13
  • 28
3
votes
3 answers

Partial platform specific methods in .NET MAUI

I'm trying to implement plattform specific partial method in .NET MAUI to get the connection string for the database. In the "main application": namespace TestApp.DL; public partial class BaseHandler { public partial string GetDBPath(); …
Cliffhanger
  • 1,057
  • 1
  • 9
  • 18
3
votes
1 answer

Class instance fails isinstance check

Hi I have some code on my CI failing (local runs do not fail). The problem is that class instance fails isinstance() check. Code: File: main.py class MyController(SuperController): # Overrides default definition of get_variables_context() …
Peter Zaitcev
  • 316
  • 1
  • 14