.net

LINQ to entities Query to randomize row selection.

I am writing an app using .NET, C#, LINQ to entities and SQL Server 2008. I would like to pick a row randomly from a table. Is there a way to achieve this using the LINQ queries. One approach would be to get a list of rows from the table and then pick one of them randomly, which is very straight forward. Just curious, if there is a way...

When defining a binding purely in XAML, can the source variable be accessed in the code behind?

I'm learning binding in WPF. I can get binding to work when 1) the text of one control goes directly to the text field of another and 2) when I manually configure binding in the code-behind file. In the first scenario, I use purely XAML to configure the binding. Is it possible to access the source variable from XAML in the code-behi...

What are some good alternatives to multiple-inheritance in .NET?

I've run into a bit of a problem with my class hierarchy, in a WPF application. It's one of those issues where you have two inheritance trees merging together, and you can't find any logical way to make your inheritance work smoothly without multiple inheritance. I'm wondering if anyone has any bright ideas for getting this kind of syste...

Is there a testing tool to test a C# .net web service that contains complex types?

I have built a C# .net web service that takes a complex type as a parameter. Is there a testing tool that I can run against my web service and pass all of the values to the complex parameter type? Some background info: I ran the xsd.exe tool against my XSD and have created a .cs class. This .cs class has the dataset that is used as my...

Detect windows mobile device

Excuse the newbness of this, I'm not getting very far relying on google and intuition alone :S. I need to add the facility to a windows application, I have already developed, to detect the presence of a windows mobile device (win CE 5.0) and then copy a specific file to that device and copy a different file from that device back to the ...

MVC/MVP/MVVM - How to organize business logic

This post is similar to http://stackoverflow.com/questions/534233/in-mvc-mvp-mvpc-where-do-you-put-your-business-logic, but I'm looking for more detail. I've bought into the Model as the place where the vast majority of business logic should reside. However, the Model, as far as I understand has a lot going on inside it: application st...

.NET type with a "2" suffix?

I vaguely remember there is a .NET type name with the suffix "2". I can't remember exactly which one it is though. Can anyone point it out to me? Thanks ...

XSD.exe /dataset is not creating enumerations from my xsd file

I have created an XSD and have run XSD.exe on top of that .xsd file. It seems that my simple types that are restricted to enumeration values are not being generated as enums in the outputted .cs file. For example, my xsd looks like this: <xs:element name="ItemList" nillable="false"> <xs:complexType> <xs:sequence minOccurs="1" maxOc...

Project Reference in RDLC ReportViewer Report

I have a Visual Studio 2005 solution which contains two projects - a Windows Forms project in VB and a class library in C#. My VB project includes an RDLC report file. I have recently learned that you can add custom code and external references to an RDLC report. I would like to reference my C# class library from the RDLC file (which, ...

Can't get my SSIS package to run

I created and deployed a package to SQL Server 2005. The package basically downloads a file (.csv) via FTP and extracts the contents to a table. The data is cleaned and then the data is moved to a production table. After deploying the package, I tried calling it from a simple .NET application Dim app As New Application Dim pk...

.NET DataReader and ORDER BY

Is it normal behaviour for a DataReader to return the rows from a query out-of-order? I'm fetching some rows from a PostgreSQL 8.3.7 database and am using ORDER BY, LIMIT and OFFSET as follows: SELECT id, name FROM tbl_foo ORDER BY name LIMIT 10 OFFSET 0; If I run this query manually the results are sorted and then the first ten rows...

C# Custom Object Validation Design

I currently have to validate custom Field Objects for my application. Simply put, each Field object consists of information about the validation for the field, as well as the value of the field. I am validating fields in bulk, so currently, I have a validation class, that has a method for each validation. For required fields, it looks so...

Business objects frameworks for C# and .net

Is there any other open source BusinessObjects framework available like CSLA for C#? ...

How to group items by index? C# LINQ

Suppose I have var input = new int[] { 0, 1, 2, 3, 4, 5 }; How do I get them grouped into pairs? var output = new int[][] { new int[] { 0, 1 }, new int[] { 2, 3 }, new int[] { 4, 5 } }; Preferably using LINQ ...

login authentication system c# .net

I have a simple site with a simple db. i want the ability to have some sort of login system. there will be 2 types of user: Admins and Non-Admins How can i easily create a login system using my existing database. i have read around using membership providers and using the tool aspnet_regsql.exe but dont know too much. i'm working in c#...

Is there any way to prevent a file from being moved in .NET?

I am loading assemblies dynamically and need to prevent being loaded files from being moved via file move or file cut and paste. Windows does prevent the loaded assemblies from being deleted. However, I can still move the files to different directories in the same volume. Do you know of any way to prevent a file from being moved? Tha...

How do I attach a trace listener to a running process?

I'm not sure if this is possible in the manner I am envisioning or not so I'm hoping someone can help me wrap my head around this. I'm wanting to inject a TraceListener into a running process - kind of. I don't actually care how I attach to the process, but the end goal is to listen to the trace output of the running process and dump i...

How to get the index of an element in an IEnumerable?

I wrote this: public static class EnumerableExtensions { public static int IndexOf<T>(this IEnumerable<T> obj, T value) { return obj .Select((a, i) => (a.Equals(value)) ? i : -1) .Max(); } public static int IndexOf<T>(this IEnumerable<T> obj, T value , IEqualityComparer<T> comp...

c# redirect (pipe) process output to another process

Hi I am trying to run a process in c# using the Process class. Process p1 = new process(); p1.startinfo.filename = "xyz.exe"; p1.startinfo.arguments = //i am building it based on user's input. p1.start(); So based on user input i am building the argument value. Now i have a case where i have to pipe the output of p1 to another proc...

How do I unit test code that uses a Fluent interface?

I've created a few small fluent interfaces through method chaining. They typically call a number of Repositories that fetch data from webservices / databases. How should I go about unit testing methods that use the fluent interface? Public IEnumberable<Computer> FindComputers(string serialNumber) { return Computers.FindBySerialNu...