Daily Archives

Articles indexed Wednesday March 31 2010

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

  • MVC 2 Entity Framework View Model Insert

    - by cannibalcorpse
    This is driving me crazy. Hopefully my question makes sense... I'm using MVC 2 and Entity Framework 1 and am trying to insert a new record with two navigation properties. I have a SQL table, Categories, that has a lookup table CategoryTypes and another self-referencing lookup CategoryParent. EF makes two nav properties on my Category model, one called Parent and another called CategoryType, both instances of their respective models. On my view that creates the new Category, I have two dropdowns, one for the CategoryType and another for the ParentCategory. When I try and insert the new Category WITHOUT the ParentCategory, which allows nulls, everything is fine. As soon as I add the ParentCategory, the insert fails, and oddly (or so I think) complains about the CategoryType in the form of this error: 0 related 'CategoryTypes' were found. 1 'CategoryTypes' is expected. When I step through, I can verifiy that both ID properties coming in on the action method parameter are correct. I can also verify that when I go to the db to get the CategoryType and ParentCategory with the ID's, the records are being pulled fine. Yet it fails on SaveChanges(). All that I can see is that my CategoryParent dropdownlistfor in my view, is somehow causing the insert to bomb. Please see my comments in my httpPost Create action method. My view model looks like this: public class EditModel { public Category MainCategory { get; set; } public IEnumerable<CategoryType> CategoryTypesList { get; set; } public IEnumerable<Category> ParentCategoriesList { get; set; } } My Create action methods look like this: // GET: /Categories/Create public ActionResult Create() { return View(new EditModel() { CategoryTypesList = _db.CategoryTypeSet.ToList(), ParentCategoriesList = _db.CategorySet.ToList() }); } // POST: /Categories/Create [HttpPost] public ActionResult Create(Category mainCategory) { if (!ModelState.IsValid) return View(new EditModel() { MainCategory = mainCategory, CategoryTypesList = _db.CategoryTypeSet.ToList(), ParentCategoriesList = _db.CategorySet.ToList() }); mainCategory.CategoryType = _db.CategoryTypeSet.First(ct => ct.Id == mainCategory.CategoryType.Id); // This db call DOES get the correct Category, but fails on _db.SaveChanges(). // Oddly the error is related to CategoryTypes and not Category. // Entities in 'DbEntities.CategorySet' participate in the 'FK_Categories_CategoryTypes' relationship. // 0 related 'CategoryTypes' were found. 1 'CategoryTypes' is expected. //mainCategory.Parent = _db.CategorySet.First(c => c.Id == mainCategory.Parent.Id); // If I just use the literal ID of the same Category, // AND comment out the CategoryParent dropdownlistfor in the view, all is fine. mainCategory.Parent = _db.CategorySet.First(c => c.Id == 2); _db.AddToCategorySet(mainCategory); _db.SaveChanges(); return RedirectToAction("Index"); } Here is my Create form on the view : <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary(true) %> <fieldset> <legend>Fields</legend> <div> <%= Html.LabelFor(model => model.MainCategory.Parent.Id) %> <%= Html.DropDownListFor(model => model.MainCategory.Parent.Id, new SelectList(Model.ParentCategoriesList, "Id", "Name")) %> <%= Html.ValidationMessageFor(model => model.MainCategory.Parent.Id) %> </div> <div> <%= Html.LabelFor(model => model.MainCategory.CategoryType.Id) %> <%= Html.DropDownListFor(model => model.MainCategory.CategoryType.Id, new SelectList(Model.CategoryTypesList, "Id", "Name"))%> <%= Html.ValidationMessageFor(model => model.MainCategory.CategoryType.Id)%> </div> <div> <%= Html.LabelFor(model => model.MainCategory.Name) %> <%= Html.TextBoxFor(model => model.MainCategory.Name)%> <%= Html.ValidationMessageFor(model => model.MainCategory.Name)%> </div> <div> <%= Html.LabelFor(model => model.MainCategory.Description)%> <%= Html.TextAreaFor(model => model.MainCategory.Description)%> <%= Html.ValidationMessageFor(model => model.MainCategory.Description)%> </div> <div> <%= Html.LabelFor(model => model.MainCategory.SeoName)%> <%= Html.TextBoxFor(model => model.MainCategory.SeoName, new { @class = "large" })%> <%= Html.ValidationMessageFor(model => model.MainCategory.SeoName)%> </div> <div> <%= Html.LabelFor(model => model.MainCategory.HasHomepage)%> <%= Html.CheckBoxFor(model => model.MainCategory.HasHomepage)%> <%= Html.ValidationMessageFor(model => model.MainCategory.HasHomepage)%> </div> <p><input type="submit" value="Create" /></p> </fieldset> <% } %> Maybe I've just been staying up too late playing with MVC 2? :) Please let me know if I'm not being clear enough.

    Read the article

  • Why I&rsquo;m Getting an iPad

    - by andrewbrust
    I have never purchased an Apple product in my life.  That’s a “true fact.”  And, for that matter, the last Apple product I really wanted was an Apple IIe, back in the 1980s.  I couldn’t afford it though (I was in high school), so I got a Commodore 64 instead…it had the same microprocessor, after all.  If the iPhone were on Verizon, I probably would have picked one up in December, when I got my Droid.  And if the iPod Touch worked with my Napster subscription (which of course it does not, but my Sonos does) I might have picked on of those instead. That’s three strikes, but Apple’s not out.  I’ve decided I want the iPad.  Why?  Well, to start with, my birthday is March 31st…the iPad comes out on April 3rd, and my wife wanted to know what to get me.  Also, my house is a 7-minute walk from the Apple Store on West 14th Street in Manhattan.  This makes it easy to get my pre-ordered device on launch day, and get home quickly with it.  Oh, and I agreed to write an article for Redmond Magazine, the fee for which will pay for the device…that way the birthday present doesn’t have to be an extravagant expense.  Plus, I’m a contrarian, so I want to buy the one device from Apple that the fanboys have actually panned. Think those are bad reasons? How about this: I want to experience iPhone and iPad development and, although my app will probably never hit the App Store and run on the actual device, I still think owning one will help me develop something better.  i want to see if the slate form factor has good business usage scenarios.  I want to see if Business Intelligence technology on a device like this can work.  Imagine a dashboard on this thing. And, for the consumer experience, I really want a touch device on which I can surf the Web while I’m in the kitchen, or on the couch.  I don’t want the small form factor of my phone, I don’t want to use my TV, and I don’t want a keyboard that will get dirty or in my way. I don’t want to watch movies on it (my TV is good for that), so I don’t care that the iPad has a 4:3 screen.  I don’t want to read books on it, so I don’t care that the display is backlit LCD, rather than eInk. But really what I want is to understand, first hand, why people have such brand loyalty to Apple.  I know the big reasons; I’m not detached from society.  But I want to know the subtle points of what Apple does really well, and also what they do poorly.  And I’d like to know, once and for all, if Microsoft can beat Apple, if Microsoft can think the right way to beat Apple and if Microsoft should  even try to beat Apple. I expect to share my thoughts on these questions, as they develop.

    Read the article

  • How do I profile the startup process in OS X 10.5?

    - by Alex Mcp
    When I bought my MBP 2.2 GHZ in 2007, it got from dead to an active dock in about 18 seconds, and now it takes about 1:30 to get a fully responsive home screen. I want to find a way to profile the various things it does when it starts up so I can begin tuning it a bit. Any good software or other recommendations for this process?

    Read the article

  • Floating point vs integer calculations on modern hardware

    - by maxpenguin
    I am doing some performance critical work in C++, and we are currently using integer calculations for problems that are inherently floating point because "its faster". This causes a whole lot of annoying problems and adds a lot of annoying code. Now, I remember reading about how floating point calculations were so slow approximately circa the 386 days, where I believe (IIRC) that there was an optional co-proccessor. But surely nowadays with exponentially more complex and powerful CPUs it makes no difference in "speed" if doing floating point or integer calculation? Especially since the actual calculation time is tiny compared to something like causing a pipeline stall or fetching something from main memory? I know the correct answer is to benchmark on the target hardware, what would be a good way to test this? I wrote two tiny C++ programs and compared their run time with "time" on Linux, but the actual run time is too variable (doesn't help I am running on a virtual server). Short of spending my entire day running hundreds of benchmarks, making graphs etc. is there something I can do to get a reasonable test of the relative speed? Any ideas or thoughts? Am I completely wrong? The programs I used as follows, they are not identical by any means: #include <iostream> #include <cmath> #include <cstdlib> #include <time.h> int main( int argc, char** argv ) { int accum = 0; srand( time( NULL ) ); for( unsigned int i = 0; i < 100000000; ++i ) { accum += rand( ) % 365; } std::cout << accum << std::endl; return 0; } Program 2: #include <iostream> #include <cmath> #include <cstdlib> #include <time.h> int main( int argc, char** argv ) { float accum = 0; srand( time( NULL ) ); for( unsigned int i = 0; i < 100000000; ++i ) { accum += (float)( rand( ) % 365 ); } std::cout << accum << std::endl; return 0; } Thanks in advance!

    Read the article

  • Reselling Open Source Code licenced under GPL, MIT

    - by Tempe
    I want to use some open source code that is licenced under the following "GNU General Public License (GPL), MIT License". I want to include this code in a product that i will sell. Here is the code in particular What do i have to do to not get sued? :) I dont mind distributing the source code that i have modified, but i dont want the whole application open source. If i build the open source code into a library and open source the library can i link to it and not open the rest of my source?

    Read the article

  • Exception design: Custom exceptions reading data from file?

    - by User
    I have a method that reads data from a comma separated text file and constructs a list of entity objects, let's say customers. So it reads for example, Name Age Weight Then I take these data objects and pass them to a business layer that saves them to a database. Now the data in this file might be invalid, so I'm trying to figure out the best error handling design. For example, the text file might have character data in the Age field. Now my question is, should I throw an exception such as InvalidAgeException from the method reading the file data? And suppose there is length restriction on the Name field, so if the length is greater than max characters do I throw a NameTooLongException or just an InvalidNameException, or do I just accept it and wait until the business layer gets a hold of it and throw exceptions from there? (If you can point me to a good resource that would be good too)

    Read the article

  • getting complete sql query in jython

    - by kdev
    result=sqlstring.executeQuery("select distinct table_name,owner from all_tables ") rs.append(str(i)+' , '+result.getString("table_name")+' , '+result.getString("owner")) If i want to display the query select * from all_tables or ' select count(*) from all_tables' how can i get the output to display . Please suggest thanks

    Read the article

  • Boost Regex throwing an error

    - by Srinivasa Varadan
    Hi ALL, I have the following error when I try to compile my code in g+ compiler using eclipse In function `ZSt19__iterator_categoryIPKSsENSt15iterator_traitsIT_E17iterator_categoryERKS3_': C:/Program Files (x86)/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algobase.h:(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)]+0x22): undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)' collect2: ld returned 1 exit status Build error occurred, build is stopped All I have done is this statement boost::regex re("\s+"); along with the header #inlucde Could you kindly tell me how to proceed ?

    Read the article

  • Help with Custom Workflow that monitors an objects state

    - by zSysop
    I need to write a workflow that monitors the status of an object. (It could wait for days or hours for a state to change) I have the following states for the object (lets call it an Issue object): 1) Created 2) Unowned 3) Owned 4) UnAssigned 4) Assigned 6) In Progress 7) Signed Off 8) Closed I would also need to take some action on an object if the object was within a certain state for a defined period (not really sure on how this can be accomplished either). The object's owner/assignee can change at any point (i.e. Go from In Progress to UnOwned) so i am guessing that a state machine diagram is what i would need to use. If my thinking is incorrect then please let me know. My application is written in c# .net 3.5. I was thinking about having a service method called CreateIssue that would insert the ticket into the db and then begin an instance of a workflow (with the object or an id of the object as parameters). I wasn't sure of how the workflow would then know when a particular object has been updated, or if the object's state has changed. I've done some really simple "hello world" type of apps with windows workflow foundation 3.5 but have not yet grasped how to do go about implementing something like this. Any direction on this will be extremely helpful. Thanks in advance.

    Read the article

  • ASP.NET Event delegation between user controls

    - by Ishan
    Give the following control hierarchy on a ASP.NET page: Page HeaderControl       (User Control) TitleControl       (Server Control) TabsControl       (User Control) other controls I'm trying to raise an event (or some notification) in the TitleControl that bubbles to the Page level. Then, I'd like to (optionally) register an event handler at the Page codebehind that will take the EventArgs and modify the TabsControl in the example above. The important thing to note is that this design will allow me to drop these controls into any Page and make the entire system work seamlessly if the event handler is wired up. The solution should not involve a call to FindControl() since that becomes a strong association. If no handler is defined in the containing Page, the event is still raised by TitleControl but is not handled. My basic goal is to use event-based programming so that I can decouple the user controls from each other. The event from TitleControl is only raised in some instances, and this seemed to be (in my head) the preferred approach. However, I can't seem to find a way to cleanly achieve this. Here are my (poor) attempts: Using HttpContext.Current.Items Add the EventArgs to the Items collection on TitleControl and pick it up on the TabsControl. This works but it's fundamentally hard to decipher since the connection between the two controls is not obvious. Using Reflection Instead of passing events, look for a function on the container Page directly within TitleControl as in: Page.GetType().GetMethod("TabControlHandler").Invoke(Page, EventArgs); This will work, but the method name will have to be a constant that all Page instances will have to defined verbatim. I'm sure that I'm over-thinking this and there must be a prettier solution using delegation, but I can't seem to think of it. Any thoughts?

    Read the article

  • How to distribute email's delivery between 2 or more servers

    - by user181186
    We provide Email Marketing service through our online App. We have about 30 customers. And each one has it's own mailling list (5k to 20k emails each). What we really want is to distribute email's delivery between 2 or more servers. I was wondering What kind of aproach/solutions MailChimp , Constant Contact uses to provide a great service ? use many servers ? many IPs ? Our spam policy suspends ANY user/customer that gets 10% bounced .

    Read the article

  • Run Program on Startup?

    - by Maddest Hatter
    How is it possible to have an executable run automatically on startup? Is it possible by having a shortcut to the .exe in the startup folder in the All programs section of the start menu? If that is correct, what is the full directory of the start up folder? C:/

    Read the article

  • Why is the installation of certain programs always such a pain in Linux [closed]

    - by Saif Bechan
    I am new to Linux and I am trying to set up a server. For this I sometimes to need to install special software, but the installation of this is always such a pain. For example I wanted to try the htscanner to see if it did the job for me. When i got to the page there is NO INSTALLATION guide. I had to search for the right one on google. Even on google its a pain to find the right method. Just try it - google search.After a long search and tried different things I finally found out that I had te install some more software before it will work. The website says that the version I used did not had any dependencies. Thats a lie. Release0.8.1: No dependencies registered. You do need certain things for it to work. After managing to set it up it still didn't work I can't figure out why because there is no official guide on the website. So I wanted to just uninstall it and find a better solution. Uninstalling. Uninstalling something in Linux is a real mystery how this actually works. The best answer I got is to manually look for the files and delete them. Whats up with that! There is never something said about uninstalling on the websites. Even on the website of CentOS itself it tels you how to install something like rpmforge packages (it's a miracle they tell you and not have to google it) but there is no mention of what to do when you want to uninstall. Why not? The forums you get on when trying to solve your problem are most of the time in plain text, and you have to scroll trough huge error logs before you see somethings that vaguely resembles your question if you are lucky. The Question My question is if there are any recommended websites / forums that explain the basic concepts of installing and uninstalling software on Linux. And explain other useful operations. And not Wikipedia or the first hits of Google, I have been there already. I am looking for some easy to read trough guides on these operations on Linux. I have been on a lot of websites that explain some Linux operation, but I bet its easier to get a degree in rocket science than to read trough the website and understand what they try to say.

    Read the article

  • IE not detecting jquery change method for checkbox

    - by user271619
    The code below works in FF, Safari, Chrome. But IE is giving me issues. When a checkbox is checked, I cannot get IE to detect it. $("#checkbox_ID").change(function(){ if($('#'+$(this).attr("id")).is(':checked')){ var value = "1"; }else{ var value = "0"; } alert(value); return false; }); Simply, I'm not getting that alert popup, as expected. I've even tried it this way: $("#checkbox_ID").change(function(){ if( $('#'+$(this).attr("id")'+:checked').attr('checked',false)){ var value = "1"; }else{ var value = "0"; } alert(value); return false; }); Here's the simple checkbox input: Anyone know if IE requires a different jquery method? or is my code just off?

    Read the article

  • Cheetah pre-compiled template usage quesion

    - by leo
    For performance reason as suggested here, I am studying how to used the pr-compiled template. I edit hello.tmpl in template directory as #attr title = "This is my Template" \${title} Hello \${who}! then issued cheetah-compile.exe .\hello.tmpl and get the hello.py In another python file runner.py , i have !/usr/bin/env python from Cheetah.Template import Template from template import hello def myMethod(): tmpl = hello.hello(searchList=[{'who' : 'world'}]) results = tmpl.respond() print tmpl if name == 'main': myMethod() But the outcome is ${title} Hello ${who}! Debugging for a while, i found that inside hello.py def respond(self, trans=None): ## CHEETAH: main method generated for this template if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)): trans = self.transaction # is None unless self.awake() was called if not trans: trans = DummyTransaction() it looks like the trans is None, so it goes to DummyTransaction, what did I miss here? Any suggestions to how to fix it?

    Read the article

  • How to add some complex structure in multiple places in an XML file

    - by Guillaume
    I have an XML file which has many section like the one below: <Operations> <Action [some attributes ...]> [some complex content ...] </Action> <Action [some attributes ...]> [some complex content ...] </Action> </Operations> I have to add an <Action/> to every <Operations/>. It seems that an XSLT should be a good solution to this problem: <xsl:template match="Operations/Action[last()]"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <Action>[some complex content ...]</Action> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> My problem is that the content of my <Action/> contains some xPath expressions. For example: <Action code="p_histo01"> <customScript languageCode="gel"> <gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="jelly:sql" xmlns:x="jelly:xml" xmlns:xog="http://www.niku.com/xog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sql:param value="${gel_stepInstanceId}"/> </gel:script> </customScript> </Action> The ${gel_stepInstanceId} is interpreted by my XSLT but I would like it to be copied as-is. Is that possible? How?

    Read the article

  • What VC++ compiler/linker does when building a C++ project with Managed Extension

    - by ???
    The initial problem is that I tried to rebuild a C++ project with debug symbols and copied it to test machine, The output of the project is external COM server(.exe file). When calling the COM interface function, there's a RPC call failre: COMException(0x800706BE): The remote procedure call failed. According to the COM HRESULT design, if the FACILITY code is 7, it's actually a WIN32 error, and the win32 error code is 0x6BE, which is the above mentioned "remote procedure call failed". All I do is replace the COM server .exe file, the origin file works well. When I checked into the project, I found it's a C++ project with Managed Extension. When I checking the DLL with reflector, it shows there's 2 additional .NET assembly reference. Then I checked the project setting and found nothing about the extra 2 assembly reference. I turned on the show includes option of compiler and verbose library of linker, and try to analyze whether the assembly is indirectly referenced via .h file. I've collect all the .h file and grep all the files with '#using' '#import' and the assembly file itself. There really is a '#using ' in one of the .h file but not-relevant to the referenced assembly. And about the linked .lib library files, only one of the .lib file is a side-product of another managed-extension-enabled C++ project, all others are produced by a pure, traditional C++ project. For the managed-extension-enabled C++ project, I checked the output DLL assembly, it did NOT reference to the 2 assembly. I even try to capture the access of the additional assembly file via sysinternal's filemon and procmon, but the rebuild process does NOT access these file. I'm very confused about the compile and linking process model of a VC++/CLI project, where the additional assembly reference slipped into the final assembly? Thanks in advance for any of your help.

    Read the article

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