Daily Archives

Articles indexed Tuesday April 27 2010

Page 10/121 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Simple way to return anonymous types (to make MVC using LINQ possible)

    - by BlueRaja The Green Unicorn
    I'd like to implement MVC while using LINQ (specifically, LINQ-to-entities). The way I would do this is have the Controller generate (or call something which generates) the result-set using LINQ, then return that to the View to display the data. The problem is, if I do: return (from o in myTable select o); All the columns are read from the database, even the ones (potentially dozens) I don't want. And - more importantly - I can't do something like this: return (from o in myTable select new { o.column }); because there is no way to make anonymous types type-safe! I know for sure there is no nice, clean way of doing this in 3.5 (this is not clean...), but what about 4.0? Is there anything planned, or even proposed? Without something like duck-typing-for-LINQ, or type-safe anonymous return values (it seems to me the compiler should certainly be capable of that), it appears to be nearly impossible to cleanly separate the Controller from the View.

    Read the article

  • SQLite UPSERT - ON DUPLICATE KEY UPDATE

    - by Alix Axel
    MySQL has something like this: INSERT INTO visits (ip, hits) VALUES ('127.0.0.1', 1) ON DUPLICATE KEY UPDATE hits = hits + 1; As far as I'm know this feature doesn't exist in SQLite, what I want to know is if there is any way to archive the same effect without having to execute two queries. Also, if this is not possible, what do you prefer: SELECT + (INSERT or UPDATE) or UPDATE (+ INSERT if UPDATE fails)

    Read the article

  • jqGrid inline editing event on "Esc" cancel

    - by gurun8
    Does anyone know if jqGrid inline editing throws events that can be handled? The following code is a simple example of what I'm trying to accomplish: jQuery('#list').jqGrid('editRow', 0, true, false, false, false, {onClose: function(){alert('onClose')}}, reloadGrid); I'd like to be able to handle an "Esc" cancel event. The onClose event is available with Form Editing: www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing but doesn't work with inline editing and the Inline Editing documentation doesn't supply anything event wise other than the extraparam option which is very unspecific: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing I haven't been able to figure out how to utilize the extraparam options. Suggestions?

    Read the article

  • Win32 synchronization

    - by john
    I am trying to write an application (console based),in which one thread reads information from console and another thread prints the same information back to console. I am stuck in implementing the synchronization logic . Can anyone refer me some samples. john

    Read the article

  • LicenseException for Xceed DataGrid for WPF

    - by ewall
    I have developed a simple DB-editing app using Xceed's excellent DataGrid for WPF (UX Edition version 3.7), which is now ready for deployment... except that when I run it on a machine other than the development one where it was built, I am getting the runtime exception for invalid licensing. I have included my license key in the App.xaml.cs exactly as specified in the Xceed docs, like so: public partial class App : System.Windows.Application { protected override void OnStartup(StartupEventArgs e) { Xceed.Wpf.DataGrid.Licenser.LicenseKey = "DGF37-xxxxx-xxxxx-xxxx"; base.OnStartup(e); } } The correct version of the DataGrid DLLs are being included in the setup and the application's program directory, and there are no other versions on the target machine. Debugging doesn't show me anything useful other than the LicenseException that is thrown when the code tries to use the DataGrid, with the message that reads "Xceed.Wpf.DataGrid.Licenser.LicenseKey property must be set to a valid license key in the code of your application before using this product..." Any idea what's going wrong here?

    Read the article

  • Strange behavior with complex Q object filter queries in Django

    - by HWM-Rocker
    Hi I am trying to write a tagging system for Django, but today I encountered a strange behavior in filter or the Q object (django.db.models.Q). I wrote a function, that converts a search string into a Q object. The next step would be to filter the TaggedObject with these query. But unfortunately I get a strange behavior. when I search (id=20) = Q: (AND: ('tags__tag__id', 20)) and it returns 2 Taged Objects with the ID 1127 and 132 when I search (id=4) = Q: (AND: ('tags__tag__id', 4)) and it returns also 2 Objects, but this time 1180 and 1127 until here is everything fine, but when i make a little bit more complex query like (id=4) or (id=20) = Q: (OR: ('tags__tag__id', 4), ('tags__tag__id', 20)) then it returns 4(!) Objects 1180, 1127, 1127, 132 But the object with the ID 1127 is returned twice, but thats not the behaviour I want. Do I have to live with it, and uniqify that list or can I do something different. The representation of the Q object looks fine for me. But the worst is now, when I search for (id=20) and (id=4) = Q: (AND: ('tags__tag__id', 20), ('tags__tag__id', 4)) then it returns no object at all. But why? The representation should be ok and the object with the id 1127 is tagged by both. What am I missing? Here are also the relevant parts of the classes, that are involved: class TaggedObject(models.Model): """ class that represent a tagged object """ tags = generic.GenericRelation('ObjectTagBridge', blank=True, null=True) class ObjectTagBridge(models.Model): """ Help to connect a generic object to a Tag. """ # pylint: disable-msg=W0232,R0903 content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') tag = models.ForeignKey('Tag') class Tag(models.Model): ... Thanks for your help

    Read the article

  • Why Use PHP OOP over Basic Functions and When?

    - by Codex73
    There are some posts about this matter, but I didn't clearly get when to use Object Oriented coding and when to use programmatic functions in an include. Somebody also mentioned to me that OOP is very heavy to run, and makes more workload. Is this right? Lets say I have a big file with 50 functions, why will I want to call these in a class? and not by function_name(). Should I switch and create object which holds all of my functions? What will be the advantage or specific difference? What benefits does it bring to code OOP in php ? Modularity?

    Read the article

  • A note to college students using forums to do research

    - by Malcolm Anderson
    Recently, on a software development forum, a person who shall remain nameless posted the following   Hi, Is there good material available on the net/elsewhere for the following topics? 1. Transitioning an Organisation to Scrum 2. Scrum Team Dynamics Thanks Name Withheld to protect the guilty   Of course one of the first answers the nameless one got was a link to LetMeGoogleThatForYou http://lmgtfy.com/?q=Transitioning+an+Organisation+to+Scrum     Here's a quick checklist to follow before asking geeks of any kind, a broad general question. My Suggestion, use the checklist   1) google it 2) spend at least 1 hour reading blogs and articles on the subject before bothering another human 3) ask your question in the following form     a) I am a (position, years and months in positon)     b) I am trying to accomplish (goal)     c) What I have done for my research is (spent x hours reading and y hours interviewing relevant people)     d) What I am (am not) finding in my research is the following     e) Express curiosity as to what resources you may have missed and request suggestions for your next steps. 4) When you come back after doing all the above, then you can ask almost any question you want. This checklist is also useful when you are training a new developer.

    Read the article

  • set service dependency on internet connection

    - by nccsbim071
    Hi, I have created a window service and set some dependencies like on MSMQ, MSSQLSERVER and so. Everything is working nice. but i need to send another dependency for my service. That is on internet connection. My service is responsible for sending emails. As soon my server starts, my service starts too and it finds if there is anything to send, if there is, it starts to send email, if during sending it is not able to connect to the internet it cannot send email. so i guess i should set my service dependency on internet connection too. I already set my window service dependency to MicrosoftSQL Server and Microsoft Message Queuing by editing the registry value. by adding new multi string value named "DependOnService", Type "REG_MULTI_SZ" and space separated names of the services that my service depends upon for the Data. For Microsoft SQL Server i set the value to "MSSQLSERVER" but i don't know the name of the internet service that i need to set dependency upon. how can i do this, any help please Thanks

    Read the article

  • Ways to Increase Targeted Traffic and Get Your Website Ranked High in Google For Free

    With so many web pages available on the internet you can be forgiven for thinking that there is no way at all that you could get your website ranked on the first page of Google. This however could not be further from the truth and you may be surprised at how easy it is to do this providing that you follow some guidelines and pick the keyword phrases that you wish to rank highly with carefully.

    Read the article

  • IO Exception: directory name is invalid C#

    - by Bi
    My C# application throws a System.IO.IOExcepton (The directory name is invalid) for the following code for implementing a filewatcher: public void OnChanged(object source, FileSystemEventArgs e) { DirectoryInfo dList = new DirectoryInfo(e.FullPath); FileInfo[] TxtFiles = dList.GetFiles("*.TXT"); } e.FullPath is "C:/Documents and Settings/Bi/Application Data/TestApp/Reports\\0MA01P62240_000005798_TRI_4947712701738551.TXT". If you notice it seems to append a "\\" to the path when it tracks the file. Any idea what the problem may be? Thanks

    Read the article

  • Multiple SFINAE rules

    - by Fred
    Hi everyone, After reading the answer to this question, I learned that SFINAE can be used to choose between two functions based on whether the class has a certain member function. It's the equivalent of the following, just that each branch in the if statement is split into an overloaded function: template<typename T> void Func(T& arg) { if(HAS_MEMBER_FUNCTION_X(T)) arg.X(); else //Do something else because T doesn't have X() } becomes template<typename T> void Func(T &arg, int_to_type<true>); //T has X() template<typename T> void Func(T &arg, int_to_type<false>); //T does not have X() I was wondering if it was possible to extend SFINAE to do multiple rules. Something that would be the equivalent of this: template<typename T> void Func(T& arg) { if(HAS_MEMBER_FUNCTION_X(T)) //See if T has a member function X arg.X(); else if(POINTER_DERIVED_FROM_CLASS_A(T)) //See if T is a pointer to a class derived from class A arg->A_Function(); else if(DERIVED_FROM_CLASS_B(T)) //See if T derives from class B arg.B_Function(); else if(IS_TEMPLATE_CLASS_C(T)) //See if T is class C<U> where U could be anything arg.C_Function(); else if(IS_POD(T)) //See if T is a POD type //Do something with a POD type else //Do something else because none of the above rules apply } Is something like this possible? Thank you.

    Read the article

  • css only menu popout?

    - by aslum
    I'd like to have a logo (say it's square for simplicity) with 4 links that pop up when it is moused over. These would be positioned Above, Below and to the sides of the menu/logo. Is this achievable with only CSS? Any suggestions for how one might go about doing it? Semantically I'd like to order them with in the page something like: <ul><li><a href="Homepage">Logo</a> <ul><li class="north"><a href="north">North</a></li> <li class="west"><a href="west">West</a></li> <li class="east"><a href="east">East</a></li> <li class="south"><a href="south">South</a></li> </ul> </li> </ul> But have them show up on the page like: North West Logo East South

    Read the article

  • Add CSS Class to link based on Character Count with jquery

    - by Wes
    I have links that load dynamically onto a background to make them look like buttons. Some of the links take up two lines and some of the links take up 1 line. Eithe way they need to be vertically centered. My plan to to append a class based on the number of characters and then adjust the padding from there. So if the link's text is 25 characters (including spaces) or less - append class 'small' if the link's text is greater than 25 characters - append class 'large' How would I go about doing this with jQuery?

    Read the article

  • SQL Like keyword in Dynamic Linq

    - by Erwin
    Hi fellow programmer I want to use SQL's Like keyword in dynamic LINQ. The query that I want to make is like this select * from table_a where column_a like '%search%' Where the column_a can be dynamically changed to other column etc In this dynamic LINQ var result = db.table_a.Where( a=> (a.column_a.Contains("search")) ); But the column can't be dynamically changed , only the search key can How do we create a dynamic LINQ like var result = db.table_a.Where("column_a == \"search\""); That we can change the column and the search key dynamically

    Read the article

  • How to send IM message like Skype in Android ?

    - by mob-king
    I have to build a feature in my application which allows user to send a skype message. For this I have installed skype lite client for Android (although offically the download has been currently withdrawn from Skype). Now how to initiate the activity from my application OR simply send the chat message without bringing it front, assuming I have skype installed in Android & also signed in already. Any help ? Thanks.

    Read the article

  • google maps export driving directions to kml file - java geogoogle

    - by maiky
    Hi Sorry at first for my poor grammar. I am writing a program in Java using geogoogle (Google Geocoder Java API) http://geo-google.sourceforge.net/ I need from two specific points to get the walking directions between these points and also these info to be exported in a KML file. Do you know how can I do it from Java? Is there an API that I can use? Perhaps making a call from the java program to google and handle the result - but how can it be done? Thanks in advance. PS. Google gives this functionality as i saw here http://www.gringod.com/2008/02/26/save-google-maps-driving-directions/ but I need all these to be called from Java.

    Read the article

  • Python - Things I shouldn't be doing?

    - by cornjuliox
    I've got a few questions about best practices in Python. Not too long ago I would do something like this with my code: ... junk_block = "".join(open("foo.txt","rb").read().split()) ... I don't do this anymore because I can see that it makes code harder to read, but would the code run slower if I split the statements up like so: f_obj = open("foo.txt", "rb") f_data = f_obj.read() f_data_list = f_data.split() junk_block = "".join(f_data_list) I also noticed that there's nothing keeping you from doing an 'import' within a function block, is there any reason why I should do that?

    Read the article

  • Determine if a url matches a Route, and pull out the terms if it does

    - by Kevin Montrose
    I've got a big old log file I'm trying to break down in terms of routes. Essentially, I'm getting input of a path (/questions/31415 for example) and a list of all the registered Routes. What I want out is a Route and the parameters specified in the route (so in, /questions/{id}/{answer} I'd get id and answers out). I've got a working solution that basically generates a nasty bit of regex on the fly with named groups to do matching and parsing all-in-one. My gut tells me this is a brittle way to do it, and frankly there has to be a better way, right?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >