Given this query:
from s in services
select new
{
s.Id,
s.DateTime,
Class = s.Class.Name,
s.Location,
s.Price,
HeadCount = s.Reservations.Sum(r => r.PartySize), // problem here. r.PartySize is int
s.MaxSeats
}
If the service doesn't have any reservations, this exception is thrown:
System.InvalidOperatio...
I have a class which models online campaigns i.e. people clicking through to the site from affiliate websites, and we need to record all these clicks and any purchases that are made. This class has the usual crap - name, start date, end date etc. - which we need to return and I have a constructor which populates these values. All very st...
I trying to make a visible tray-icon of my program in windows startup, with the NotifyIcon component.
The program itself works great and the tray-icon showing up.
But, when i placing my program in computer startup, the tray icon not always showing up, while the program itself is running without any problems, and its main window is visi...
I have an extension method which uses some configuration settings. I've declared these as static.
public static class Extensions
{
static string _mailServer = ConfigurationManager.AppSettings["MailServer"];
// ... etc
public static void SendEmailConfirmation(this IOrder order) { }
}
I just wanted to check that this is...
I'm finding myself needing a lot of this sort of logic lately:
Assert.That(collection.Items, Has.Member(expected_item));
Assert.That(collection.Items.Count(), Is.EqualTo(1));
I see that NUnit offers Has.Some and Has.All, but I don't see anything like Has.One. What's the best way to accomplish this without two asserts?
...
I've been reviewing an example of domain event design blogged about recently by Mike Hadlow and created originally by Udi Dahan.
Currently we are publishing static events on our domain objects and subscribing to them directly within our services, or via our plugin model (we locate and initialize our plugins at runtime using StructureMap...
Hi
I'm new to C# WPF.
There's a flowchart WPF program in C#.
The program can display objects and connecting arrows between them.
ie eg
======== ========
| | | |
| obj1 | ------> | obj2 |
======== ========
1 - How do I add a visual function to each object when right clicking them ?
ie when I r...
I am wondering if there is a cleaner way to write the (working) code below:
uint uEnum = 0;
PStore.EnumTypes(0, 0, ref uEnum);
System.Reflection.MemberInfo inf = typeof(PSTORECLib.CEnumTypes);
GuidAttribute CEnumGuid =
(GuidAttribute)inf.GetCustomAttributes(typeof(GuidAttribute), false)[0];
Guid tmp = new Guid(CEnumGuid.Value);
Int...
I know parameters to attribute declarations have to be a constant expression and resolved at compile time. However, can I play with the concept of 'compile time'? ASP.net has the concept of App_Code folder. It looks from it's description like you can drop .cs files into it, even while the app is running, and it will be brought in and com...
Hi all,
I'm working with Microsft Office Interop API. My question pertains to Excel.
I wrote a program using Interop API to format Excel documents and then send them to the printer. The problem though is that we occasionally run across files in which people have created a column that spans 65,000+ rows, and all it contains is a formula...
How to transfer IEnumerable value into InArgument in CodeActivity in Workflow
public sealed class CreateInterview : CodeActivity<int>
{
public InArgument<List<InterviewerList>> InterviewerLists { get; set; }
protected override int Execute(CodeActivityContext context)
{
var interviewerLists = context.GetValue(this.In...
How do I order by and group by in a Linq query?
I tried..
Dim iPerson = From lqPersons In objPersons Where Len(lqPersons.Person) > 0 Group lqPersons By key = lqPersons.Name Into Group Order By Group descending Select Group, key
For Each i In iPerson
tmp = tmp & vbNewLine & i.key & ", " & i.Group.Count
Next
The above ...
Hello,
I'm trying to mock an interface's events like the following:
[TestMethod]
public void NeedingDataFiresEvents()
{
//Arrange
var service = MockRepository.GenerateMock<IService>();
service.Expect(i => i.GetValue()).Return(5);
var view = MockRepository.GenerateMock<ILogView>();
view.NeedData += null;
LastCall...
I have a WPF TreeView that has ScrollViewerVerticalScrollBarVisibility set to Auto. This treeview is in a Border, which is in a Grid.
When I start my app, it populates the treeview and the length of the treeview is too long for the panel. So I'd expect a scrollbar. And as expected about 75% of the time I get one. But about 1/4 of th...
I have the following code block in C#
private void Synchronize<T>(TextSelection selection, DependencyProperty property, Action<T> methodToCall)
{
object value = selection. GetPropertyValue(property) ;
if ( value != DependencyProperty. UnsetValue) methodToCall((T) value) ;
}
That I have converted to VB.
Private Sub Synchron...
I am trying to understand the object size difference between 32 bit and 64 bit processors. Let’s say I have a simple class
class MyClass
{
int x;
int y;
}
So on a 32 bit machine, an integer is 4 bytes. If I add the Syncblock into it ( another 4 bytes), the object size will be 12 bytes. Why is it showing 16 bytes? ...
Hi
I want to know, when i cache a class with no parameters of fields, how much space it takes ?
Is it true that only fields and properties of a class consume space ?
if it is true, when i create a class with this specification is it true that it occupies only pointer to this class in cache ?
Please help me with how caching really works i...
I have a situation where, in a multithreaded application, many different threads are accessing a Dictionary at the same time. It appears that this could be a bottleneck, but it's unclear - a plausible scenario is that multiple threads may be trying to retrieve the same value (do note, however, that the data structure is fixed - no thread...
Hello,
I'm trying to create a Conversation Item like the ones Office Communicator saves in Conversation History in Outlook.
So far I've achieved to get the mail icon replaces with the real "speech bubble" icon and the window title is also writing "Subject - Conversation(HTML)" but some things are missing.
I.e. when opening the real co...
Hello,
I am looking to do this:
container.Resolve();
When it does this, its going to inject a IDependency into the underlying entity object. However, the dependency stored within the container requires an object of type DependencyValue, which is supplied a value from a DependencyFactory. So long story short, the issue I'm having is ...