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
0
votes
1 answer

Conditionally Disable Validation in Model Partial Class

I have a partial class with validation attributes - [MetadataTypeAttribute(typeof(tblPersonMetadata))] public partial class tblPerson { } public class tblPersonMetadata { [MaxLength(80)] public string PER_MiddleName { get; set; } …
Don
  • 1,532
  • 4
  • 24
  • 47
0
votes
0 answers

What is the execution order of the fields in partial classes?

public class Report { public static int A = B + 2; public static int B = A + 2; } AFAIK, in a class it executes the fields in the order of their presence in the class. Referring the first time to Report class, the fields will be initialized…
serdar
  • 1,564
  • 1
  • 20
  • 30
0
votes
1 answer

Hybrid implementation for an entity and MVC

Using Microsoft Entity Framework and MVC, I have the following requirement, implement an entity where some properties belong to a table within a sql server DB, and other properties are loaded from an XML column on the same table, I'd like to create…
0
votes
3 answers

Extend linq-to-sql partial class to avoid writing a property?

I have a linq-to-sql class. I have a property "Password" for which I want to call the underlying ASP.NET Membership provider. Thus, I do not want this property written out directly but via my own code. I basically want to create a facade/proxy for…
0
votes
2 answers

Entity Framework Custom field persistence

I am using the Entity Framework with a database first approach. I have used partial classes to successfully add custom methods, but have found that if I add a custom field it is not persisted when my entity is next pulled from the DataContext…
waxingsatirical
  • 584
  • 1
  • 7
  • 11
0
votes
1 answer

Python: combining making two scripts into one

I have two separately made python scripts one that makes a sine wave sound based off time, and another that produces a sine wave graph that is based off the same time factors. I need help combining them into one running file. Here's the first: from…
Alex
  • 53
  • 4
0
votes
2 answers

Group Properties within partial class

I have 5 Properties within my class that are all very similar; I want to group them. The class they are contained in used to look like this: class Car { public string PropA { get; set; } public string PropB { get; set; } public string PropC…
user3761858
  • 231
  • 2
  • 6
  • 13
0
votes
0 answers

Upgrading to Entity Framework 6

I am upgrading from EF4 to EF6 and have problems of getting the model to work. I use VS2012. First I didn't get any code generated which under EF4 worked automatically. I changed EntityModel's Code Generation Strategy from None to Default and got…
Nuts
  • 2,755
  • 6
  • 33
  • 78
0
votes
1 answer

partial class with interface with it

I am having two namespaces with two classes with same Name something like this "public partial class CustomerDetail" one from "namespace MS.Client" which implements "IClient" Interface and another one from "namespace MS.Customer" which implements…
0
votes
2 answers

What's the convention for extending Linq datacontext with set based helper operations specific to one collection of entities only

I might be vaguing out here but I'm looking for a nice place to put set based helper operations in linq so I can do things like; db.Selections.ClearTemporary() which does something like db.DeleteAllOnSubmit(db.Selections.Where(s =>…
Luke Rohde
  • 261
  • 3
  • 14
0
votes
1 answer

mvc2 validation problem (ambiguous reference between model and models)

I followed instructions for mvc validation but I can't manage to solve this problem.... This is linq to sql model: DB Model http://img443.imageshack.us/img443/6049/structure.gif I set Entity namespace to be CMS.Model If I try to declare partial…
ilija veselica
  • 9,414
  • 39
  • 93
  • 147
0
votes
1 answer

Error when projecting partial class properties. The specified type member 'Password' is not supported in LINQ to Entities

I am using MVC4 DatabaseFirst with EF 5. I get this exception: "The specified type member 'Password' is not supported in LINQ to Entities." My code: Auto generated class by EF using DB First approach // auto-generated-class public partial…
0
votes
2 answers

simulating C++ friendship in C# with partial classes

I have the following situation: I need to create a tree-like structure that once instantiated, is immutable .Think a list of list approach for instance. The problem is that during construction, I need to be able to insert nodes. So I need some sort…
SaldaVonSchwartz
  • 3,769
  • 2
  • 41
  • 78
0
votes
1 answer

How can we change the datatype of a property in a Partial class?

Hi am kind of new to MVC, The .tt file corresponding to the table in the DB, has a data type as String for Gender. I have manually declared an enum for Gender in my C# class. I have also implemented the Partial class concept and used metadata to…
Vicky-Torres
  • 219
  • 2
  • 8
0
votes
2 answers

WPF .how can i access to fields in other Forms without get new object

I have a MainWindow and a DetailedBookView . i want use Method and field from DetailedBookView in MainWindow class whit out using new object... MainWindows isn't parent of DetailedBook ... please help me to write code in MainWindow to use…