partial-classes

C# - what's the major problem solved by "partial" classes?

I'm asking this because I find it quite a dangerous feature to distribute the class definition so that you can't really be sure if you know all about it. Even if I find three partial definitions, how do I know that there's not a fourth somewhere? I'm new to C# but have spent 10 years with C++, maybe that's why I'm shaken up? Anyway, th...

implicit conversion - strongly typed datatable to datatable ???

Not sure why I'm getting this error. Project is converted from VS 2005, to VS 2008, but remains with 2.0 framework.. image of the error message Here is the interface with my generic type and constraint.... public interface ITableAdapter<DT> where DT:System.Data.DataTable { /// <summary> /// Must be called immediately after...

Naming Conventions For Partial Class Files

I'm generating the bulk of my ASP.NET MVC scaffolding code. All generated files are partial classes which use standard naming conventions. For example, my employee controller file is named EmployeeController.cs. If I wish to extend the EmployeeController with custom, non-generated logic, I create a second partial class file named Employ...

MVC Partial Controls

Ok I have a menu system with a menu (Dynamicly Generated from a datavbase field) I want to include this menu system on several views - All of which use differant controllers and models. <ul> <li><a href="#">All</a></li> <% foreach (var curCat in Model.CategoryList) { ...

C++ partial method specialization

Is there a partial specialization for template class method? template <class A, class B> class C { void foo(); } it doesn't work to specialize it like this: template <class A> void C<A, CObject>::foo() {}; Any help? ...

Partial Class Constructors

Is there a way to have a partial class' constructor call another method that my or may not be defined? Basically my partial class constructor is defined: public partial class Test { public Test() { //do stuff } } I would like to be able to somehow insert extra code to be run after the class constructor is cal...

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 (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { obj = thi...

LINQ to SQL testing

Hi I'm using Linq to sql to access an SQL Server. I try to write all my database queries in a partial class so they can be accessed directly from the DataContext. Now I would like to test the Data Context but I can't figure out the best way och doing that. Bascially I need to test 3 things: 1. The queries return the correct data (no...

Nested link_to_function/insert_html does not work

Here is a simple example of the problem. http://gist.github.com/235729 In short, if you have a index.rhtml with: <%= link_to_function "A link to insert a partial with nested insert_html" do |page| page.insert_html :top, :with_a_nested_insert_html, :partial => 'example_partial_with_nested_insert_html' end %> And a _example_...

Model - Partial class and Datacontext class are not communicating.

Hello, I've created a one table contact DB, which has only 3 columns (Id, Name, and Phone). I've then created the ContactsDataContext using my table Contacts in the model folder. Finally, I create a partial class still in the model folder (public partial class Contact). now when I write this public partial class Contact { public...

Under what conditions it is good to have a "partial class?"

When does it become a good idea to have your class separate into two .cs and have it as a partial class? Are there some signs showing that it is time to go with partial class? Thanks! ...

Using partial classes to add private properties?

I have a public class I'm defining that will eventually be part of an API, so it has to have certain public properties. However, I also want some of the properties to be read-only unless they're created from within my own projects (e.g., if a user has our API, they can create a User object, but they can't write to its ID field, which wil...

Can i call a function defined in one partial class from another partial class. Is it possible ?

I have created two partial classes for a web page. Now i have given a defination of one function say submit() that i m calling at OnSubmit event of button. But this function is not being called, the program doesnot compiles as it is not able to search the defination of function, which was defined in another partial class. Is it possi...

Why cant partial methods be public if the implementation is in the same assembly?

According to this http://msdn.microsoft.com/en-us/library/wa80x488.aspx "Partial methods are implicitly private" So you can have this // Definition in file1.cs partial void Method1(); // Implementation in file2.cs partial void Method1() { // method body } But you cant have this // Definition in file1.cs public partial void Metho...

Can I extend a EntityCollection<Class> : LINQ to SQL

Can I extend or use partial classes to add more functions to EntityCollection< Class> eg. this is the auto-generated classses from LINQ to SQL customer.Orders I want to be able to do customer.Orders.FindByOrderID(orderID) but Order is EntityCollection < Order > Can I make this a partial class or extend it like I can do with just...

Partial classes/partial methods vs base/inherited classes

Hello folks, 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 other empty) Specific Repository implementation Class (implements what is left...

NUnit, TestDriven.Net: Duplicate test results with partial test classes

I just discovered that I was getting twice the number of tests run that I should've been getting. Discovered it when a test broke and I got two identical test failures. Same test, same everything. Got me quite confused, but managed to narrow it down to a certain test class that was a partial class. The reason it was a partial class was ...

Problem with DataAnnotations in partial class

So in my mvc project's Project.Repository I have [MetadataType(typeof(FalalaMetadata))] public partial class Falala { public string Name { get; set; } public string Age { get; set; } internal sealed class FalalaMetadata { [Required(ErrorMessage="Falala requires name.")] public string Name { get; set; } ...

Linq-to-SQL design

I am using the VS Report Viewer control and stored procedures to print forms from a web application (in PDF and streamed to the client). These documents have between 1 to 200 pages, roughly, and process the same amount of rows. Not much. Any data retrieval code needs to know about business rules. For instance, there are accounts, and ac...

C# Partial Classes

I currently have a solution with multiple projects that mostly use the same classes. As a result, it appeared to me that it would be a good idea to add a class library containing these classes in the solution instead of repeating the class in each project. However, one project I have requires a few additional properties to some of the ...