How to write sub queries like these in EF?
select * from table1 where col1 in (select col1 from table2 where col2 = 'xyz')
or
select * from table1 where col1 not in (select col1 from table2 where col2 = 'xyz')
I tried something like these
from t1 in table1
where (from t2 in table2 where col2 = 'xyz' select t2.col1).Contains(t1.col...
In a Windows Service, I need to detect when the computer goes into sleep and when it wakes up, and run some code on these events. This needs to be done for sleep, standby and hibernate power modes.
How do I do that ?
...
I have an array of bytes (say byte[] data), which contains text with custom line delimiters, for example: "\r\n" (CRLF "\x0D\x0A"), "\r", "\n", "\x0D\x0A\x0D" or even "@".
At the moment I'm going to use the following solution:
Normalize line breaks to CRLF (here is an example how to normalize CRLF http://stackoverflow.com/questions/84...
I have a data structure (which is a class) called user_class and I want to load all the users data from a database.
Currently I have
While SQLreader.Read()
Hold_user.username = SQLreader(0)
Hold_user.BlahBlahBlah = SQLreader(1)
Hold_user.Secret_Password = SQLreader(2)
return_value.Add(Hold_us...
Is there a library written in .NET that allows me to read a video frame by frame?
Sample usage could be as follows:
Video vid = Video.Open("test.avi");
foreach (Bitmap bmp in vid.Frames)
PictureBox1.Picture = bmp;
...
I have an ASP.NET application and need to store some settings.
The settings are, among other things, titles on pages shown in my application. The titles are changed on a regular basis (every week or so) and I'm wondering on how to do this the smart way:
Save the settings in the web.config (slow read time, and application has to be re...
I am fairly new to C# programming and I am stuck on my little ASP.NET project.
My website currently examines Twitter statuses for URLs and then adds those URLs to an array, all via a regular expression pattern matching procedure. Clearly more than one person will update a with a specific URL so I do not want to list duplicates, and I wa...
As I assume static methods shouldn't be writen like the first snippet , or am I wrong ?
public static class ExtensionClass
{
private static SomeClass object1;
private static StringBuilder sb;
private static string DoSomething()
{
sb.AppendLine(object1.SomeValue);
}
public static string ExtensionMethod(this HtmlHelper helper,...
As the title says how can I store a hexadecimal number in a variable without it becoming a decimal. Or do I have to store it as either a string or integer?
...
The regex foo/(\w*)/bar matches the string foo/123/bar.
This is probably something basic that I've missed about regexes, but often I only want to retrieve the substring between the slashes. Is there a simple .NET API I can use without having to access the groups collection? Or an alternative way of writing the regex?
Thanks!
...
Hello all.
I have a SQLCommand :
"Update Customers Set Name = @name
where code = @code"
and this code:
cmd.Parameters[0].Value = "بهروز";//(some Unicode characters)
cmd.Parameters[1].Value = 1;
cmd.ExecuteNonQuery();
or this code:
UpdateCommand.CommandText = "UPDATE [Customers] SET [Name] = @p1 WHERE (([Code]...
I have a .NET program that does some displaying by drawing on a system.drawing.drawing2d.graphics object. I'd like to be able to turn each "frame" drawn into a frame in an .avi file.
Are there AVI classes in .NET? Some simple way to get the bitmap that must underlie the graphics object?
Thanks in advance.
...
I have an array (Items) which holds lots of instances of a class (Item).
Item has 2 properties, a Group and an ID.
there may be more than Item in the array(Items) that have the same Group and ID properties.
How do I "search"/get the first Item which matches a specified Group and/or ID
Something like:
Item.getbygroup([group]) which re...
Is it ok to roll your own localization framework? I would be ok using the default .NET localization behavior (i.e., putting text in resource files named a certain way in the assembly), except that we have localized images and text that need to be rendered in DirectX in addition to WinForms and WPF.
I could put form-specific strings in ...
I have this code sample:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
if (Request.IsAuthenticated) {
%>
Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>!
The catch is I am putting the user's id and not name into the 'username' field:
User user = _userRepository.Get(...);
FormsAuthent...
I have a situation where I need to generate SSL certificates for clients using SslStream as a server.
I know how to do that (makecert.exe), but I run into a problem when trying to ensure that both sides of the connection are authenticated.
Basically, if I use self signed cert, I need to add it to the trusted roots to get mutual authent...
Sup Guys,
I Have a Function on my frmMain Class wich will update my control to something else after an invoke. When i type "?Label1.Text" on the Immediate Window, the text property IS updated, but when i go check the Form, nothing happened. The code is just like this
Public Sub UpdateUI()
If (Me.InvokeRequired = True) Then
...
I have a property which is an array of items but when I come to add an item to the array it says I must use the new keyword, but I can't use a new keyboard with a property.
(item is a custom class)
Private itemsvalue As item()
Public Property Items() As item()
Get
Return itemsvalue
End Get
Set(ByVal value As DBPFind...
Hi everyone,
Quick question, what's the preferable way to programmaticaly ask "Is there exactly one element in this sequence that satisfies X condition?" using Linq?
i.e.
// Pretend that the .OneAndOnlyOne() method exists
int[] sequence = new int[] { 1, 1, 2, 3, 5, 8 };
Assert.IsTrue(sequence.OneAndOnlyOne(x => x == 2);
Assert.IsFalse...
I'm interested in creating a desktop application to help organize large image collections.
Are there any libraries out there that aid in the creation of huge thumbnail galleries, with the ability to "group" and display these thumbnails at arbitrary positions? Also the ability to scale them would be nice as well.
Is this something I'm ...