Daily Archives

Articles indexed Saturday March 13 2010

Page 17/89 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Joins in LINQ to SQL

    - by rajbk
    The following post shows how to write different types of joins in LINQ to SQL. I am using the Northwind database and LINQ to SQL for these examples. NorthwindDataContext dataContext = new NorthwindDataContext(); Inner Join var q1 = from c in dataContext.Customers join o in dataContext.Orders on c.CustomerID equals o.CustomerID select new { c.CustomerID, c.ContactName, o.OrderID, o.OrderDate }; SELECT [t0].[CustomerID], [t0].[ContactName], [t1].[OrderID], [t1].[OrderDate]FROM [dbo].[Customers] AS [t0]INNER JOIN [dbo].[Orders] AS [t1] ON [t0].[CustomerID] = [t1].[CustomerID] Left Join var q2 = from c in dataContext.Customers join o in dataContext.Orders on c.CustomerID equals o.CustomerID into g from a in g.DefaultIfEmpty() select new { c.CustomerID, c.ContactName, a.OrderID, a.OrderDate }; SELECT [t0].[CustomerID], [t0].[ContactName], [t1].[OrderID] AS [OrderID], [t1].[OrderDate] AS [OrderDate]FROM [dbo].[Customers] AS [t0]LEFT OUTER JOIN [dbo].[Orders] AS [t1] ON [t0].[CustomerID] = [t1].[CustomerID] Inner Join on multiple //We mark our anonymous type properties as a and b otherwise//we get the compiler error "Type inferencce failed in the call to 'Join’var q3 = from c in dataContext.Customers join o in dataContext.Orders on new { a = c.CustomerID, b = c.Country } equals new { a = o.CustomerID, b = "USA" } select new { c.CustomerID, c.ContactName, o.OrderID, o.OrderDate }; SELECT [t0].[CustomerID], [t0].[ContactName], [t1].[OrderID], [t1].[OrderDate]FROM [dbo].[Customers] AS [t0]INNER JOIN [dbo].[Orders] AS [t1] ON ([t0].[CustomerID] = [t1].[CustomerID]) AND ([t0].[Country] = @p0) Inner Join on multiple with ‘OR’ clause var q4 = from c in dataContext.Customers from o in dataContext.Orders.Where(a => a.CustomerID == c.CustomerID || c.Country == "USA") select new { c.CustomerID, c.ContactName, o.OrderID, o.OrderDate }; SELECT [t0].[CustomerID], [t0].[ContactName], [t1].[OrderID], [t1].[OrderDate]FROM [dbo].[Customers] AS [t0], [dbo].[Orders] AS [t1]WHERE ([t1].[CustomerID] = [t0].[CustomerID]) OR ([t0].[Country] = @p0) Left Join on multiple with ‘OR’ clause var q5 = from c in dataContext.Customers from o in dataContext.Orders.Where(a => a.CustomerID == c.CustomerID || c.Country == "USA").DefaultIfEmpty() select new { c.CustomerID, c.ContactName, o.OrderID, o.OrderDate }; SELECT [t0].[CustomerID], [t0].[ContactName], [t1].[OrderID] AS [OrderID], [t1].[OrderDate] AS [OrderDate]FROM [dbo].[Customers] AS [t0]LEFT OUTER JOIN [dbo].[Orders] AS [t1] ON ([t1].[CustomerID] = [t0].[CustomerID]) OR ([t0].[Country] = @p0)

    Read the article

  • Code Bubbles: Disruption comes to the IDE

    - by andrewbrust
    If you’re like me, you might see the open source Eclipse IDE as a copy or, more generously, a port of the Microsoft’s Visual Studio for the non-.NET world.  It’s not that Microsoft invented the IDE (I would credit Borland with that), but they really took the idea and ran with it for the first version of Visual Studio .NET in 2002.  The question is whether someone outside of Microsoft could take the modern IDE yet another major step forward in both principle and productivity. I think that has actually happened already, and I think the innovator in question is a second-year Computer Science PhD student at Brown, named Andrew Bragdon.  His project, which he calls Code Bubbles, is an IDE that allows for editing, debugging and exploration of code in “bubbles” which remind me a little bit of the discrete note tiles on OneNote…but they’re much more than that.  Bubbles actually allow for call stack traversal, saved debug sessions, sophisticated breakpoint and value watch behaviors and more.  And because bubbles, unlike windows, are borderless, and focus on code fragments rather than whole files, the de-cluttering effect is unbelievably liberating.  The best way to understand what Code Bubbles does is to watch the screencast video:     Code Bubbles is an IDE for Java development.  Why didn’t Microsoft come up with something like this for .NET devs?  Between the existing features in Visual Studio 2010, its WPF code editor, and the fact that OneNote’s UI bears some affinity to Code Bubbles’, it’s interesting that Microsoft still has not thought outside of its own “box” to get us something like this. Heck, that’s easy for me to say.  But it’s easy for you to say that you’d like something like this in Visual Studio sometime soon.  That’s because the ASP.NET site within UserVoice is taking votes on this very issue.  Just click this link and vote! Thanks to my fellow Microsoft Regional Director Sondre Bjellås for making me aware of Code Bubbles, and to RD Steve Smith for creating the UserVoice voting option.

    Read the article

  • Django admin site auto populate combo box based on input

    - by user292652
    hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two = models.ForeignKey('Team', related_name='Team_two') Stadium = models.CharField(max_length=255, blank=True) Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True, null=True) Rafree = models.CharField(max_length=255, blank=True) Judge = models.CharField(max_length=255, blank=True) Winner = models.ForeignKey('Team', related_name='winner', blank=True) updated = models.DateTimeField('update date', auto_now=True ) created = models.DateTimeField('creation date', auto_now_add=True ) def save(self, force_insert=False, force_update=False): pass @models.permalink def get_absolute_url(self): return ('view_or_url_name') class MatchAdmin(admin.ModelAdmin): list_display = ('Team_one','Team_two', 'Winner') search_fields = ['Team_one','Team_tow'] admin.site.register(Match, MatchAdmin) i was wondering is their a way to populated the winner combo box once the team one and team two is selected in admin site ?

    Read the article

  • C/C++ packing signed char into int

    - by aaa
    hello I have need to pack four signed bytes into 32-bit integral type. this is what I came up to: int byte(char c) { return (unsigned char)c; } int pack(char c0, char c1, ...) { return byte(c0) | byte(c1) << 8 | ...; } is this a good solution? Is it portable? is there a ready-made solution, perhaps boost? Thanks

    Read the article

  • Delphi - most successful applications developed

    - by Juraj Blahunka
    Can you name famous, successful applications, applications in development, future applications, that are developed with Delphi? The kind of applications that you use everyday is encouraged. Some of i know: Total Commander TopStyle Skype PHP Designer edit I'm not very interested in listing of applications taken from google. Just the kind of apps that you really find useful and are fond of. (and of course are programmed with delphi :))

    Read the article

  • Finite State Machine Spellchecker

    - by Durell
    I would love to have a debugged copy of the finite state machine code below. I tried debugging but could not, all the machine has to do is to spell check the word "and",an equivalent program using case is welcomed. #include<cstdlib> #include<stdio.h> #include<string.h> #include<iostream> #include<string> using namespace std; char in_str; int n; void spell_check() { char data[256]; int i; FILE *in_file; in_file=fopen("C:\\Users\\mytorinna\\Desktop\\a.txt","r+"); while (!feof(in_file)) { for(i=0;i<256;i++) { fscanf(in_file,"%c",in_str); data[i]=in_str; } //n = strlen(in_str); //start(data); cout<<data; } } void start(char data) { // char next_char; //int i = 0; // for(i=0;i<256;i++) // if (n == 0) { if(data[i]="a") { state_A(); exit; } else { cout<<"I am comming"; } // cout<<"This is an empty string"; // exit();//do something here to terminate the program } } void state_A(int i) { if(in_str[i] == 'n') { i++; if(i<n) state_AN(i); else error(); } else error(); } void state_AN(int i) { if(in_str[i] == 'd') { if(i == n-1) cout<<" Your keyword spelling is correct"; else cout<<"Wrong keyword spelling"; } } int main() { spell_check(); system("pause"); return 0; }

    Read the article

  • creating new usercntrols at runtime in ASP.NET MVC

    - by Paul Connolly
    Hi everyone, My situation is that the user is creating an entity on my site which contains the particlars of the driectors of that company, name address etc.. The Director form is a separate user control with the appropriate textboxes etc. At run time we don't know how many of these directors there will be so I need one to be able to use something like an "ADD DIRECTOR" or "DELETE DIRECTOR" button which will present or delete the another usercontrol to add the additional director. Currently I am trying to make this happen within a pane of the JQuery Accordion control. I have looked many places for how to do this but to no avail. Can anyone tell me where I might find some inforamation about how I can do this? All the best Paul

    Read the article

  • Converting QXmlItem to QtDomElement or similar?

    - by EightyEight
    Hello everyone. I'm parsing a fairly complicated XML file of the following structure: <root> ... ... <item> <subitem id="1"/> <text> text1 </text> </item> <item> <subitem id="2"/> <text> text2 </text> </item> ... <item> ... </item> ...</root> It's pretty crude but you get my drift I hope. I'm primarily interested in "item" nodes. So I wrote the following code (directly out of the Qt's online manual): QXmlQuery query; query.setQuery("//item/"); QXmlResultItems result; query.evaluateTo(&result); QXmlItem item(result.next()); while (!item.isNull()) { if (item.isNode()) { // WHAT DO I DO NOW? } item = result.next(); } Now, QXmlItem appears to represent two concepts, a literal value (like a string) or a Node, (which is what item.isNode() is doing). Unfortunately, I can't grasp how to convert the QXmlItem to something that will query-able again. In particular from the example above I'd like to grab the "id" attribute, and the text element. Can I do this using the XQuery approach, or am I way off base here? Any advice? Thanks!

    Read the article

  • Flash or good JavaScripit Image Filmstrip

    - by Ben
    I have looked all over the internet for this and I can't find one anywhere. I'm just looking for a simple flash or a nice javascript filmstrip. I'm happy to pay for this too. Only features it must have are, resizable and be able to add remove images etc. Thanks Ben

    Read the article

  • Eclipse standard warning/error overlay icons

    - by pulzar
    I'm writing an Eclipse plug-in... In my custom label decorator, I want to overlay a warning icon, and I'd like to use the standard one used by eclipse (the little yellow triangle). How can I get an image descriptor of this icon? I tried using workbench.getSharedImages().getImageDescriptor(ISharedImages .IMG_DEC_FIELD_WARNING), since that ID seems to match what I'm looking for, but the shared images collection doesn't actually have that image in it (so I just get a null returned). Is there some other shared image collection that I should be looking at?

    Read the article

  • Optimal Sharing of heavy computation job using Snow and/or multicore

    - by James
    Hi, I have the following problem. First my environment, I have two 24-CPU servers to work with and one big job (resampling a large dataset) to share among them. I've setup multicore and (a socket) Snow cluster on each. As a high-level interface I'm using foreach. What is the optimal sharing of the job? Should I setup a Snow cluster using CPUs from both machines and split the job that way (i.e. use doSNOW for the foreach loop). Or should I use the two servers separately and use multicore on each server (i.e. split the job in two chunks, run them on each server and then stich it back together). Basically what is an easy way to: 1. Keep communication between servers down (since this is probably the slowest bit). 2. Ensure that the random numbers generated in the servers are not highly correlated.

    Read the article

  • AutoMapper with c# 2.0 syntax

    - by Morri
    I'm trying to create a custom mapping with AutoMapper, but I can't use 3.0 syntax with lambdas. How would one convert this 3.0 code into 2.0 ? Mapper.CreateMap<MyClass, MyDto>() .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.CompanyName)) Edit: Since there was no better solution, we are now using vs2008 on one workstation to make these mappings and build a dll. I hope it won't be long until we upgrade to vs2010.

    Read the article

  • For kernel/OS is C still it

    - by Recursion
    I like operating systems and would eventually like to become a OS developer mostly working on kernels. In the future will C still be the language of choice and what else should I be trying to learn.

    Read the article

  • Performing both client side and server side validation using jQuery and CodeIgniter

    - by Vasu
    What is the right way of doing both client side and server side validation using jQuery and CodeIgniter? I am using the jQuery form plugin for form submit. I would like to use jQuery validation plugin (http://docs.jquery.com/Plugins/Validation) for client side validation and CodeIgniter form validation on the server side. However the two don't seem to gel together (or I am unable to get my head around it). Can someone help please? Whether its a client side validation or server side validation, the user should see consistent UI displaying error messages next to the input fields.

    Read the article

  • SQL Error with Order By in Subquery

    - by cagin
    Hi all. i m working sql server 2005. My query is: SELECT ( SELECT COUNT(1) FROM Seanslar WHERE MONTH(tarihi) = 4 GROUP BY refKlinik_id ORDER BY refKlinik_id) as dorduncuay And the error: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. How can i use order by in a sub query?

    Read the article

  • Hierarchical object model with property inheritance and event bubbling?

    - by Winston Fassett
    I'm writing a document-based client application and I need a DOM or WPF-like, but non-visual model that: Is a tree composed of elements Can accept an unlimited number of custom properties that get/set any CLR type, including collections. Can inherit their values from their parent Can inherit their default values from an ancestor Can be derived/calculated from other properties, ancestors, or descendants Support event bubbling / tunneling There will be a core set of properties but other plugins may add their own or even create custom documents Supports full inspection by the owning document in order to persist the tree and attributes in an XML format. I realize that's a tall order but I was really hoping there would be something out there to help me get started. Unfortunately WPF DependencyObjects are too closed, proprietary, and coupled to WPF to be of any use as a document model. My needs also have a strong resemblance to the HTML DOM but I haven't been able to find any clean DOM implementations that could be decoupled from HTML or ported to .NET. My current platform is .NET/C# but if anyone knows of anything that might be useful for inspiration or embedding, regardless of the platform, I'd love to know.

    Read the article

  • Amazon mount EBS

    - by William
    I'm trying to mount /vol to a EBS volume on an Amazon EC2 instance. I'm formatting the device to xfs, adding "/dev/sdh /vol xfs noatime 0 0" to my /etc/fstab file, making the /vol dir and mounting it and whenever I try to do anything with that volume (create a file in /vol, cd, ls, anything) or I try to run df the server just freezes. Anyone have any idea what this might be? It's driving me crazy. Edit: It seems to freeze after I mount, has nothing to do with doing any commands to the volume it's self.

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >