Search Results

Search found 2870 results on 115 pages for 'james outer'.

Page 14/115 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Counting the number of objects that meets a certain criteria

    - by Candy Chiu
    The title doesn't tell the complete story. Please read the message. I have two objects: Adult and Child. Child has a boolean field isMale, and a reference to Adult. Adult doesn't reference Child. public class Adult { long id; } public class Child { long id; boolean isMale; Adult parent; } I want to create a query to list the number of sons each adult has including adults who don't have any sons. I tried: Query 1 SELECT adult, COUNT(child) FROM Child child RIGHT OUTER JOIN child.parent as adult WHERE child.isMale='true' GROUP BY adult which translates to sql select adult.id as col_0_0_, count(child.id) as col_1_0_, ... {omit properties} from Child child right outer join Adult adult on child.parentId=adult.id where child.isMale = 'true' group by adult.id Query 1 doesn't pick up adults that don't have any sons. Query 2: SELECT adult, COUNT(child.isMale) FROM Child child RIGHT OUTER JOIN child.parent as adult GROUP BY adult translates to sql: select adult.id as col_0_0_, count(child.id) as col_1_0_, ... {omit properties} from Child child right outer join Adult adult on child.parentId=adult.id group by adult.id Query 2 doesn't have the right count of sons. Basically COUNT doesn't evaluate isMale. The where clause in Query 1 filtered out Adults with no sons. How do I build a HQL or a Criteria query for this use case? Thanks.

    Read the article

  • How to exit an if clause

    - by Roman Stolper
    What sorts of methods exist for prematurely exiting an if clause? There are times when I'm writing code and want to put a break statement inside of an if clause, only to remember that those can only be used for loops. Lets take the following code as an example: if some_condition: ... if condition_a: # do something # and then exit the outer if block ... if condition_b: # do something # and then exit the outer if block # more code here I can think of one way to do this: assuming the exit cases happen within nested if statements, wrap the remaining code in a big else block. Example: if some_condition: ... if condition_a: # do something # and then exit the outer if block else: ... if condition_b: # do something # and then exit the outer if block else: # more code here The problem with this is that more exit locations mean more nesting/indented code. Alternatively, I could write my code to have the if clauses be as small as possible and not require any exits. Does anyone know of a good/better way to exit an if clause? If there are any associated else-if and else clauses, I figure that exiting would skip over them.

    Read the article

  • How to properly translate the "var" result of a lambda expression to a concrete type?

    - by CrimsonX
    So I'm trying to learn more about lambda expressions. I read this question on stackoverflow, concurred with the chosen answer, and have attempted to implement the algorithm using a console app in C# using a simple LINQ expression. My question is: how do I translate the "var result" of the lambda expression into a usable object that I can then print the result? I would also appreciate an in-depth explanation of what is happening when I declare the outer => outer.Value.Frequency (I've read numerous explanations of lambda expressions but additional clarification would help) C# //Input : {5, 13, 6, 5, 13, 7, 8, 6, 5} //Output : {5, 5, 5, 13, 13, 6, 6, 7, 8} //The question is to arrange the numbers in the array in decreasing order of their frequency, preserving the order of their occurrence. //If there is a tie, like in this example between 13 and 6, then the number occurring first in the input array would come first in the output array. List<int> input = new List<int>(); input.Add(5); input.Add(13); input.Add(6); input.Add(5); input.Add(13); input.Add(7); input.Add(8); input.Add(6); input.Add(5); Dictionary<int, FrequencyAndValue> dictionary = new Dictionary<int, FrequencyAndValue>(); foreach (int number in input) { if (!dictionary.ContainsKey(number)) { dictionary.Add(number, new FrequencyAndValue(1, number) ); } else { dictionary[number].Frequency++; } } var result = dictionary.OrderByDescending(outer => outer.Value.Frequency); // How to translate the result into something I can print??

    Read the article

  • How do I make this nested for loop, testing sums of cubes, more efficient?

    - by Brian J. Fink
    I'm trying to iterate through all the combinations of pairs of positive long integers in Java and testing the sum of their cubes to discover if it's a Fibonacci number. I'm currently doing this by using the value of the outer loop variable as the inner loop's upper limit, with the effect being that the outer loop runs a little slower each time. Initially it appeared to run very quickly--I was up to 10 digits within minutes. But now after 2 full days of continuous execution, I'm only somewhere in the middle range of 15 digits. At this rate it may end up taking a whole year just to finish running this program. The code for the program is below: import java.lang.*; import java.math.*; public class FindFib { public static void main(String args[]) { long uLimit=9223372036854775807L; //long maximum value BigDecimal PHI=new BigDecimal(1D+Math.sqrt(5D)/2D); //Golden Ratio for(long a=1;a<=uLimit;a++) //Outer Loop, 1 to maximum for(long b=1;b<=a;b++) //Inner Loop, 1 to current outer { //Cube the numbers and add BigDecimal c=BigDecimal.valueOf(a).pow(3).add(BigDecimal.valueOf(b).pow(3)); System.out.print(c+" "); //Output result //Upper and lower limits of interval for Mobius test: [c*PHI-1/c,c*PHI+1/c] BigDecimal d=c.multiply(PHI).subtract(BigDecimal.ONE.divide(c,BigDecimal.ROUND_HALF_UP)), e=c.multiply(PHI).add(BigDecimal.ONE.divide(c,BigDecimal.ROUND_HALF_UP)); //Mobius test: if integer in interval (floor values unequal) Fibonacci number! if (d.toBigInteger().compareTo(e.toBigInteger())!=0) System.out.println(); //Line feed else System.out.print("\r"); //Carriage return instead } //Display final message System.out.println("\rDone. "); } } Now the use of BigDecimal and BigInteger was delibrate; I need them to get the necessary precision. Is there anything other than my variable types that I could change to gain better efficiency?

    Read the article

  • What is this: main:for(...){...} doing?

    - by David Murdoch
    I pulled up the NWmatcher source code for some light morning reading and noticed this odd bit of code I'd never seen in javascript before: main:for(/*irrelevant loop stuff*/){/*...*/} This snippet can be found in the compileGroup method on line 441 (nwmatcher-1.1.1) return new Function('c,s,d,h', 'var k,e,r,n,C,N,T,X=0,x=0;main:for(k=0,r=[];e=N=c[k];k++){' + SKIP_COMMENTS + source + '}return r;' ); Now I figured out what main: is doing on my own. If you have a loop within a loop and want to skip to the next iteration of the outer loop (without completing the inner OR the outer loop) you can execute continue main. Example: // This is obviously not the optimal way to find primes... function getPrimes(max) { var primes = [2], //seed sqrt = Math.sqrt, i = 3, j, s; outer: for (; i <= max; s = sqrt(i += 2)) { j = 3; while (j <= s) { if (i % j === 0) { // if we get here j += 2 and primes.push(i) are // not executed for the current iteration of i continue outer; } j += 2; } primes.push(i); } return primes; } What is this called? Are there any browsers that don't support it? Are there other uses for it other than continue?

    Read the article

  • T-SQL Query, combine columns from multiple rows into single column

    - by Shayne
    I have seeen some examples of what I am trying to do using COALESCE and FOR XML (seems like the better solution). I just can't quite get the syntax right. Here is what I have (I will shorten the fields to only the key ones): Table Fields ------ ------------------------------- Requisition ID, Number IssuedPO ID, Number Job ID, Number Job_Activity ID, JobID (fkey) RequisitionItems ID, RequisitionID(fkey), IssuedPOID(fkey), Job_ActivityID (fkey) I need a query that will list ONE Requisition per line with its associated Jobs and IssuedPOs. (The requisition number start with "R-" and the Job Number start with "J-"). Example: R-123 | "PO1; PO2; PO3" | "J-12345; J-6780" Sure thing Adam! Here is a query that returns multiple rows. I have to use outer joins, since not all Requisitions have RequisitionItems that are assigned to Jobs and/or IssuedPOs (in that case their fkey IDs would just be null of course). SELECT DISTINCT Requisition.Number, IssuedPO.Number, Job.Number FROM Requisition INNER JOIN RequisitionItem on RequisitionItem.RequisitionID = Requisition.ID LEFT OUTER JOIN Job_Activity on RequisitionItem.JobActivityID = Job_Activity.ID LEFT OUTER JOIN Job on Job_Activity.JobID = Job.ID LEFT OUTER JOIN IssuedPO on RequisitionItem.IssuedPOID = IssuedPO.ID

    Read the article

  • Linq to Entities Joins

    - by Bob Avallone
    I have a question about joins when using Linq to Entities. According to the documentation the use on the join without a qualifier performs like a left outer join. However when I execute the code below, I get a count returned of zero. But if I comment out the three join lines I get a count of 1. That would indicate that the join are acting as inner join. I have two questions. One which is right inner or outer as the default? Second how do I do the other one i.e. inner or outer? The key words on inner and outer do not work. var nprs = (from n in db.FMCSA_NPR join u in db.FMCSA_USER on n.CREATED_BY equals u.ID join t in db.LKUP_NPR_TYPE on n.NPR_TYPE_ID equals t.ID join s in db.LKUP_AUDIT_STATUS on n.NPR_STATUS_ID equals s.ID where n.ROLE_ID == pRoleId && n.OWNER_ID == pOwnerId && n.NPR_STATUS_ID == pNPRStatusId && n.ACTIVE == pActive select n).ToList(); if (nprs.Count() == 0) return null;

    Read the article

  • LINQ - 'Could not translate expression' with previously used and proven query condition

    - by tomfumb
    I am fairly new to LINQ and can't get my head around some inconsistency in behaviour. Any knowledgeable input would be much appreciated. I see similar issues on SO and elsewhere but they don't seem to help. I have a very simple setup - a company table and an addresses table. Each company can have 0 or more addresses, and if 0 one must be specified as the main address. I'm trying to handle the cases where there are 0 addresses, using an outer join and altering the select statement accordingly. Please note I'm currently binding the output straight to a GridView so I would like to keep all processing within the query. The following DOES work IQueryable query = from comp in context.Companies join addr in context.Addresses on comp.CompanyID equals addr.CompanyID into outer // outer join companies to addresses table to include companies with no address from addr in outer.DefaultIfEmpty() where (addr.IsMain == null ? true : addr.IsMain) == true // if a company has no address ensure it is not ruled out by the IsMain condition - default to true if null select new { comp.CompanyID, comp.Name, AddressID = (addr.AddressID == null ? -1 : addr.AddressID), // use -1 to represent a company that has no addresses MainAddress = String.Format("{0}, {1}, {2} {3} ({4})", addr.Address1, addr.City, addr.Region, addr.PostalCode, addr.Country) }; but this displays an empty address in the GridView as ", , ()" So I updated the MainAddress field to be MainAddress = (addr.AddressID == null ? "" : String.Format("{0}, {1}, {2} {3} ({4})", addr.Address1, addr.City, addr.Region, addr.PostalCode, addr.Country)) and now I'm getting the Could not translate expression error and a bunch of spewey auto-generated code in the error which means very little to me. The condition I added to MainAddress is no different to the working condition on AddressID, so can anybody tell me what's going on here? Any help greatly appreciated.

    Read the article

  • mysql to codeigniter active record help

    - by JoeM05
    Active record is a neet concept but sometimes I find it difficult to get more complicated queries to work. I find this is at least one place the CI docs are lacking. Anyway, This is the sql I wrote. It returns the expected results of quests not yet completed by the user that are unlocked and within the users level requirements: SELECT writing_quests . * FROM `writing_quests` LEFT OUTER JOIN members_quests_completed ON members_quests_completed.quest_id = writing_quests.id LEFT OUTER JOIN members ON members.id = $user_id WHERE writing_quests.unlocked =1 AND writing_quests.level_required <= $userlevel AND members_quests_completed.user_id IS NULL This is the codeigniter active record query, it returns all quests that are unlocked and within the users level requirement: $this->db->select('writing_quests.*'); $this->db->from('writing_quests'); $this->db->join('members_quests_completed', 'members_quests_completed.quest_id = writing_quests.id', 'left outer'); $this->db->join('members', "members.id = $user_id", 'left outer'); $this->db->where('writing_quests.unlock', 1); $this->db->where('writing_quests.level_required <=', $userlevel); $this->db->where('members_quests_completed.user_id is null', null, true); I'm guessing there is something wrong with the way I am asking for Nulls. To be thorough, I figured I'd include everything.

    Read the article

  • Back from Russia

    - by Stephen Walther
    Thanks everyone who came to my talks on ASP.NET Web Forms and MVC in Moscow last week!  Here are the slide decks and demo code for the two talks (You need Visual Studio 2010):   What’s New in ASP.NET MVC 2?   What’s New in ASP.NET 4 Web Forms?   I had a great time in Russia. On the second day, I had an opportunity to walk around Moscow. Here’s a picture of me standing in Red Square:   Here’s a picture of me eating Chicken Kiev with Microsoft evangelist James Senior. James has just started his worldwide Web Camp tour to promote ASP.NET 4. He is traveling non-stop country to country. After Russia, he is off to China and Australia. You can find out more about the Web Camps here: http://www.webcamps.ms/

    Read the article

  • 2D Barcode Addendum

    - by Tim Dexter
    Having finally got my external drive back(long story) today from Oklahoma (thank you so much Sammy) Im back with a full compliment of Oracle and blogging tools at my disposal. I have missed JDeveloper this past week, which I have found, I immensely prefer over Eclipse (let the flaming commence :0) I use Zoundry Raven for writing articles and its not installed locally but on my external drove, so I have been soldiering on with the blog server's pain in the backside UI for writing. Now I have my favority editor back and things are calming down workwise, I will start to get the Excel template posts out. Today thou, a note about 2D barcode support or more specifically any barcode that needs some data manipulation before the barcode font is applied. I wrote about these fonts a long time back and laid out the java class you would need to write if you had an algorithm from the font manufacturer to use. I missed out a valuable point and James at Luminex fell into the trap. He was wanting to use the datamatrix font from IDAutomation but and had built the java class to be called from the RTF template but it was not encoding or at least did not appear to be. New debugging feature to the rescue. Kan over at the bipconsultng blog documented the feature a while back. Just adding <?xdo-debug-level:'STATEMENT'?> to my test template generated all the debug files in my c:\temp directory. No messing with files, just a simple command ... at last! Kan has documented the feature here. With the log in hand I spotted a java error stack referencing a missing code128a method, huh? Looking at James' class he had the following snippet: ENCODERS.put("code128a",mUtility.getClass().getMethod("code128a",clazz)); ENCODERS.put("code128b",mUtility.getClass().getMethod("code128b", clazz)); ENCODERS.put("code128c",mUtility.getClass().getMethod("code128c", clazz)); ENCODERS.put("pdf417",mUtility.getClass().getMethod("pdf417", clazz)); ENCODERS.put("datamatrix",mUtility.getClass().getMethod("datamatrix", clazz)); His class did not include the other code128 and pdf147 methods and BIP was expecting them. An easy fix, just comment them out, rebuild and deploy and the encoding started working. If you are hitting similar problems, check that class and ensure all of the referenced methods are available, if not, delete or get commenting. James now has purdy labels popping out that his hard ware can read, sweet!

    Read the article

  • links for 2010-04-07

    - by Bob Rhubart
    James McGovern: Enterprise Architecture and Social CRM "With a few exceptions, the vast majority of enterprise architects I know spend an awful lot of time focused on internal issues whether it is rationalization, the cloud, storage governance, data center consolidation, creation of reference architectures, portfolio management and other considerations that aren’t even visible to customers. One should ask whether IT can be truly successful if we are busy listening to the business but otherwise are blissfully ignorant towards the customers they serve." -- James McGovern (tags: enterprisearchitecture crm socialcomputing) WRF Benchmark: X6275 Beats Power6 - BestPerf "Oracle's Sun Blade X6275 cluster is 28% faster than the IBM POWER6 cluster on Weather Research and Forecasting (WRF) continental United Status (CONUS) benchmark datasets. The Sun Blade X6275 cluster used a Quad Data Rate (QDR) InfiniBand connection along with Intel compilers and MPI." (tags: oracle sun x6275 benchmarks)

    Read the article

  • Even EA's Have Bad Days - it's Time to Reset

    - by Pat Shepherd
    I saw this article and thought I'd share it because, even we EA's have bad days and the 7 points listed are a great way for you to hit the "reset" button. From Geoffrey James on INC.COM, here are 7 ways to change your view of things when, say, you are hitting a frustration point coordinating stakeholders to agree on an approach (never happens, right?) Positive Thinking: 7 Easy Ways to Improve a Bad Day http://www.inc.com/geoffrey-james/positive-thinking-7-easy-ways-to-improve-a-bad-day.html To paraphrase:          You can decide (in an instant) to change patterns of the past          Believe in (or even visualize) good things happening, and they will          Keep a healthy perspective on the work-life / life-life continuum (what things REALLY matter in the big scheme of things)                  Focus on the good (the laws of positive-attraction apply)

    Read the article

  • OpenJDK DIO Project Now Live! Java SE Embedded API Accessing Peripherals

    - by hinkmond
    The DIO project on OpenJDK is now live! For those who grew up in the 1970's and 1980's, you might remember Ronnie James Dio, lead singer of Black Sabbath after Ozzy was fired, and lead singer of his own band, Dio. Well, this DIO is not that Dio. This DIO is the OpenJDK Device I/O project which provides a Java-level API for accessing generic device peripherals on embedded devices, like your Raspberry Pi running Java SE Embedded software. See: OpenJDK DIO Project Here's a quote: + General Purpose Input/Output (GPIO) + Inter-Integrated Circuit Bus (I2C) + Universal Asynchronous Receiver/Transmitter (UART) + Serial Peripheral Interface If you're familiar with Pi4J, then you're going to like DIO. And, if you liked Ozzy, you probably liked Ronnie James Dio. This will probably make Robert Savage happy too. The part about DIO being live now, not the part about Dio replacing Ozzy, because everyone likes Ozzy. Hinkmond

    Read the article

  • Podcast Show Notes: The Role of the Cloud Architect

    - by Bob Rhubart
    Ron Batra James Baty If you want to understand what a cloud architect does, what better way than to talk to people in that role? In this program that’s exactly what we’ll do. Joining me for this conversation are cloud architects Ron Batra and Dr. James Baty. Ron is an Oracle ACE Director and product director for cloud computing at AT&T , and Jim is Vice President of Oracle’s Global Enterprise Architecture Program . This interview was recorded on June 12, 2012. The Conversation Listen to Part 1: How cloud computing is driving the supply-chaining of IT and the democratization of the activity of architecture. Listen to Part 2 (July 12): A discussion of DevOps, cloud computing, and the increasing velocity of IT. Listen to Part 3 (July 19): Why architects need to up their game to thrive and succeed in a cloud-driven world. Coming Soon A conversation about the International SOA, Cloud & Service Technology Symposium with a panel that features Thomas Erl and several Oracle community members who will be presenting at that event.

    Read the article

  • Where'd My Data Go? (and/or...How Do I Get Rid of It?)

    - by David Paquette
    Want to get a better idea of how cascade deletes work in Entity Framework Code First scenarios? Want to see it in action? Stick with us as we quickly demystify what happens when you tell your data context to nuke a parent entity. This post is authored by Calgary .NET User Group Leader David Paquette with help from Microsoft MVP in Asp.Net James Chambers. We got to spend a great week back in March at Prairie Dev Con West, chalk full of sessions, presentations, workshops, conversations and, of course, questions.  One of the questions that came up during my session: "How does Entity Framework Code First deal with cascading deletes?". James and I had different thoughts on what the default was, if it was different from SQL server, if it was the same as EF proper and if there was a way to override whatever the default was.  So we built a set of examples and figured out that the answer is simple: it depends.  (Download Samples) Consider the example of a hockey league. You have several different entities in the league including games, teams that play the games and players that make up the teams. Each team also has a mascot.  If you delete a team, we need a couple of things to happen: The team, games and mascot will be deleted, and The players for that team will remain in the league (and therefore the database) but they should no longer be assigned to a team. So, let's make this start to come together with a look at the default behaviour in SQL when using an EDMX-driven project. The Reference – Understanding EF's Behaviour with an EDMX/DB First Approach First up let’s take a look at the DB first approach.  In the database, we defined 4 tables: Teams, Players, Mascots, and Games.  We also defined 4 foreign keys as follows: Players.Team_Id (NULL) –> Teams.Id Mascots.Id (NOT NULL) –> Teams.Id (ON DELETE CASCADE) Games.HomeTeam_Id (NOT NULL) –> Teams.Id Games.AwayTeam_Id (NOT NULL) –> Teams.Id Note that by specifying ON DELETE CASCADE for the Mascots –> Teams foreign key, the database will automatically delete the team’s mascot when the team is deleted.  While we want the same behaviour for the Games –> Teams foreign keys, it is not possible to accomplish this using ON DELETE CASCADE in SQL Server.  Specifying a ON DELETE CASCADE on these foreign keys would cause a circular reference error: The series of cascading referential actions triggered by a single DELETE or UPDATE must form a tree that contains no circular references. No table can appear more than one time in the list of all cascading referential actions that result from the DELETE or UPDATE – MSDN When we create an entity data model from the above database, we get the following:   In order to get the Games to be deleted when the Team is deleted, we need to specify End1 OnDelete action of Cascade for the HomeGames and AwayGames associations.   Now, we have an Entity Data Model that accomplishes what we set out to do.  One caveat here is that Entity Framework will only properly handle the cascading delete when the the players and games for the team have been loaded into memory.  For a more detailed look at Cascade Delete in EF Database First, take a look at this blog post by Alex James.   Building The Same Sample with EF Code First Next, we're going to build up the model with the code first approach.  EF Code First is defined on the Ado.Net team blog as such: Code First allows you to define your model using C# or VB.Net classes, optionally additional configuration can be performed using attributes on your classes and properties or by using a Fluent API. Your model can be used to generate a database schema or to map to an existing database. Entity Framework Code First follows some conventions to determine when to cascade delete on a relationship.  More details can be found on MSDN: If a foreign key on the dependent entity is not nullable, then Code First sets cascade delete on the relationship. If a foreign key on the dependent entity is nullable, Code First does not set cascade delete on the relationship, and when the principal is deleted the foreign key will be set to null. The multiplicity and cascade delete behavior detected by convention can be overridden by using the fluent API. For more information, see Configuring Relationships with Fluent API (Code First). Our DbContext consists of 4 DbSets: public DbSet<Team> Teams { get; set; } public DbSet<Player> Players { get; set; } public DbSet<Mascot> Mascots { get; set; } public DbSet<Game> Games { get; set; } When we set the Mascot –> Team relationship to required, Entity Framework will automatically delete the Mascot when the Team is deleted.  This can be done either using the [Required] data annotation attribute, or by overriding the OnModelCreating method of your DbContext and using the fluent API. Data Annotations: public class Mascot { public int Id { get; set; } public string Name { get; set; } [Required] public virtual Team Team { get; set; } } Fluent API: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Mascot>().HasRequired(m => m.Team); } The Player –> Team relationship is automatically handled by the Code First conventions. When a Team is deleted, the Team property for all the players on that team will be set to null.  No additional configuration is required, however all the Player entities must be loaded into memory for the cascading to work properly. The Game –> Team relationship causes some grief in our Code First example.  If we try setting the HomeTeam and AwayTeam relationships to required, Entity Framework will attempt to set On Cascade Delete for the HomeTeam and AwayTeam foreign keys when creating the database tables.  As we saw in the database first example, this causes a circular reference error and throws the following SqlException: Introducing FOREIGN KEY constraint 'FK_Games_Teams_AwayTeam_Id' on table 'Games' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. To solve this problem, we need to disable the default cascade delete behaviour using the fluent API: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Mascot>().HasRequired(m => m.Team); modelBuilder.Entity<Team>() .HasMany(t => t.HomeGames) .WithRequired(g => g.HomeTeam) .WillCascadeOnDelete(false); modelBuilder.Entity<Team>() .HasMany(t => t.AwayGames) .WithRequired(g => g.AwayTeam) .WillCascadeOnDelete(false); base.OnModelCreating(modelBuilder); } Unfortunately, this means we need to manually manage the cascade delete behaviour.  When a Team is deleted, we need to manually delete all the home and away Games for that Team. foreach (Game awayGame in jets.AwayGames.ToArray()) { entities.Games.Remove(awayGame); } foreach (Game homeGame in homeGames) { entities.Games.Remove(homeGame); } entities.Teams.Remove(jets); entities.SaveChanges();   Overriding the Defaults – When and How To As you have seen, the default behaviour of Entity Framework Code First can be overridden using the fluent API.  This can be done by overriding the OnModelCreating method of your DbContext, or by creating separate model override files for each entity.  More information is available on MSDN.   Going Further These were simple examples but they helped us illustrate a couple of points. First of all, we were able to demonstrate the default behaviour of Entity Framework when dealing with cascading deletes, specifically how entity relationships affect the outcome. Secondly, we showed you how to modify the code and control the behaviour to get the outcome you're looking for. Finally, we showed you how easy it is to explore this kind of thing, and we're hoping that you get a chance to experiment even further. For example, did you know that: Entity Framework Code First also works seamlessly with SQL Azure (MSDN) Database creation defaults can be overridden using a variety of IDatabaseInitializers  (Understanding Database Initializers) You can use Code Based migrations to manage database upgrades as your model continues to evolve (MSDN) Next Steps There's no time like the present to start the learning, so here's what you need to do: Get up-to-date in Visual Studio 2010 (VS2010 | SP1) or Visual Studio 2012 (VS2012) Build yourself a project to try these concepts out (or download the sample project) Get into the community and ask questions! There are a ton of great resources out there and community members willing to help you out (like these two guys!). Good luck! About the Authors David Paquette works as a lead developer at P2 Energy Solutions in Calgary, Alberta where he builds commercial software products for the energy industry.  Outside of work, David enjoys outdoor camping, fishing, and skiing. David is also active in the software community giving presentations both locally and at conferences. David also serves as the President of Calgary .Net User Group. James Chambers crafts software awesomeness with an incredible team at LogiSense Corp, based in Cambridge, Ontario. A husband, father and humanitarian, he is currently residing in the province of Manitoba where he resists the urge to cheer for the Jets and maintains he allegiance to the Calgary Flames. When he's not active with the family, outdoors or volunteering, you can find James speaking at conferences and user groups across the country about web development and related technologies.

    Read the article

  • "Yes, but that's niche."

    - by Geertjan
    JavaOne 2012 has come to an end though it feels like it hasn't even started yet! What happened, time is a weird thing. Too many things to report on. James Gosling's appearance at the JavaOne community keynote was seen, by everyone (which is quite a lot) of people I talked to, as the highlight of the conference. It was interesting that the software for the Duke's Choice Award winning Liquid Robotics that James Gosling is now part of and came to talk about is a Swing application that uses the WorldWind libraries. It was also interesting that James Gosling pointed out to the conference: "There are things you can't do using HTML." That brings me to the wonderful counter argument to the above, which I spend my time running into a lot: "Yes, but that's niche." It's a killer argument, i.e., it kills all discussions completely in one fell swoop. Kind of when you're talking about someone and then this sentence drops into the conversation: "Yes, but she's got cancer now." Here's one implementation of "Yes, but that's niche": Person A: All applications are moving to the web, tablet, and mobile phone. That's especially true now with HTML5, which is going to wipe away everything everywhere and all applications are going to be browser based. Person B: What about air traffic control applications? Will they run on mobile phones too? And do you see defence applications running in a browser? Don't you agree that there are multiple scenarios imaginable where the Java desktop is the optimal platform for running applications? Person A: Yes, but that's niche. Here's another implementation, though it contradicts the above [despite often being used by the same people], since JavaFX is a Java desktop technology: Person A: Swing is dead. Everyone is going to be using purely JavaFX and nothing else. Person B: Does JavaFX have a docking framework and a module system? Does it have a plugin system?  These are some of the absolutely basic requirements of Java desktop software once you get to high end systems, e.g., banks, defence force, oil/gas services. Those kinds of applications need a web browser and so they love the JavaFX WebView component and they also love the animated JavaFX charting components. But they need so much more than that, i.e., an application framework. Aren't there requirements that JavaFX isn't meeting since it is a UI toolkit, just like Swing is a UI toolkit, and what they have in common is their lack, i.e., natively, of any kind of application framework? Don't people need more than a single window and a monolithic application structure? Person A: Yes, but that's niche. In other words, anything that doesn't fit within the currently dominant philosophy is "niche", for no other reason than that it doesn't fit within the currently dominant philosophy... regardless of the actual needs of real developers. Saying "Yes, but that's niche", kills the discussion completely, because it relegates one side of the conversation to the arcane and irrelevant corners of the universe. You're kind of like Cobol now, as soon as "Yes, but that's niche" is said. What's worst about "Yes, but that's niche" is that it doesn't enter into any discussion about user requirements, i.e., there's so few that need this particular solution that we don't even need to talk about them anymore. Note, of course, that I'm not referring specifically or generically to anyone or anything in particular. Just picking up from conversations I've picked up on as I was scurrying around the Hilton's corridors while looking for the location of my next presentation over the past few days. It does, however, mean that there were people thinking "Yes, but that's niche" while listening to James Gosling pointing out that HTML is not the be-all and end-all of absolutely everything. And so this all leaves me wondering: How many applications must be part of a niche for the niche to no longer be a niche? And what if there are multiple small niches that have the same requirements? Don't all those small niches together form a larger whole, one that should be taken seriously, i.e., a whole that is not a niche?

    Read the article

  • Updates about Multidimensional vs Tabular #ssas #msbi

    - by Marco Russo (SQLBI)
    I recently read the blog post from James Serra Tabular model: Not ready for prime time? (read also the comments because there are discussions about a few points raised by James) and the following post from Christian Wade Multidimensional or Tabular. In the last 2 years I worked with many companies adopting Tabular in different scenarios and I agree with some of the points expressed by James in his post (especially about missing features in Tabular if compared to Multidimensional), but I strongly disagree in others. In general, Tabular is a good choice for a new project when: the development team does not have a good knowledge of Multidimensional and MDX (DAX is faster to learn, not so easy as it is sold by MS, but definitely easier than MDX) you don’t need calculations based on hierarchies (common in certain financial applications, but not so common as it could seem) there are important calculations based on distinct count measures there are complex calculations based on many-to-many relationships Until now, I never suggested to migrate an existing Multidimensional model to a Tabular one. There should be very important reasons for that, such as performance issues in distinct count and many-to-many relationships that cannot be easily solved by optimizing the Multidimensional model, but I still never encountered this scenario. I would say that in 80% of the new projects, you might use either Multidimensional or Tabular and the real difference is the time-to-market depending on the skills of the development team. So it’s not strange that who is used to Multidimensional is not moving to Tabular, not getting a particular benefit from the new model unless specific requirements exist. The recent DAXMD feature that allows using SharePoint Power View on Multidimensional is a really important one, even if I’d like having also Excel Power View enabled for this scenario (this should be just a question of time). Another scenario in which I’m seeing a growing adoption of Tabular is in companies that creates models for their product/service and do that by using XMLA or Tabular AMO 2012. I am used to call them ISVs, even if those providing services cannot be really defined in this way. These companies are facing the multitenancy challenge with Tabular and even if this is a niche market, I see some potential here, because adopting Tabular seems a much more natural choice than Multidimensional in those scenario where an analytical engine has to be embedded to deliver one of the features of a larger product/service delivered to customers. I’d like to see other feedbacks in the comments: tell your story of choosing between Tabular and Multidimensional in a BI project you started with SQL Server 2012, thanks!

    Read the article

  • Implementing Unit Testing with the iPhone SDK

    - by ing0
    Hi, So I've followed this tutorial to setup unit testing on my app when I got a little stuck. At bullet point 8 in that tutorial it shows this image, which is what I should be expecting when I build: However this isn't what I get when I build. I get this error message: Command /bin/sh failed with exit code 1 as well as the error message the unit test has created. Then, when I expand on the first error I get this: PhaseScriptExecution "Run Script" "build/3D Pool.build/Debug-iphonesimulator/LogicTests.build/Script-1A6BA6AE10F28F40008AC2A8.sh" cd "/Users/james/Desktop/FYP/3D Pool" setenv ACTION build setenv ALTERNATE_GROUP staff ... setenv XCODE_VERSION_MAJOR 0300 setenv XCODE_VERSION_MINOR 0320 setenv YACC /Developer/usr/bin/yacc /bin/sh -c "\"/Users/james/Desktop/FYP/3D Pool/build/3D Pool.build/Debug-iphonesimulator/LogicTests.build/Script-1A6BA6AE10F28F40008AC2A8.sh\"" /Developer/Tools/RunPlatformUnitTests.include:412: note: Started tests for architectures 'i386' /Developer/Tools/RunPlatformUnitTests.include:419: note: Running tests for architecture 'i386' (GC OFF) objc[12589]: GC: forcing GC OFF because OBJC_DISABLE_GC is set Test Suite '/Users/james/Desktop/FYP/3D Pool/build/Debug-iphonesimulator/LogicTests.octest(Tests)' started at 2010-01-04 21:05:06 +0000 Test Suite 'LogicTests' started at 2010-01-04 21:05:06 +0000 Test Case '-[LogicTests testFail]' started. /Users/james/Desktop/FYP/3D Pool/LogicTests.m:17: error: -[LogicTests testFail] : Must fail to succeed. Test Case '-[LogicTests testFail]' failed (0.000 seconds). Test Suite 'LogicTests' finished at 2010-01-04 21:05:06 +0000. Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.000) seconds Test Suite '/Users/james/Desktop/FYP/3D Pool/build/Debug-iphonesimulator/LogicTests.octest(Tests)' finished at 2010-01-04 21:05:06 +0000. Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.002) seconds /Developer/Tools/RunPlatformUnitTests.include:448: error: Failed tests for architecture 'i386' (GC OFF) /Developer/Tools/RunPlatformUnitTests.include:462: note: Completed tests for architectures 'i386' Command /bin/sh failed with exit code 1 Now this is very odd as it is running the tests (and succeeding as you can see my STFail firing) because if I add a different test which passes I get no errors, so the tests are working fine. But why am I getting this extra build fail? It may also be of note that when downloading solutions/templates which should work out the box, I get the same error. I'm guessing I've set something up wrong here but I've just followed a tutorial 100% correctly!! If anyone could help I'd be very grateful! Thanks EDIT: According to this blog, this post and a few other websites, I'm not the only one getting this problem. It has been like this since the release of xCode 3.2, assuming the apple dev center documents and tutorials etc are pre-3.2 as well. However some say its a known issue whereas others seem to think this was intentional. I for one would like both the extended console and in code messages, and I certainly do not like the "Command /bin/sh..." error and really think they would have documented such an update. Hopefully it will be fixed soon anyway. UPDATE: Here's confirmation it's something changed since the release of xCode 3.2.1. This image: is from my test build using 3.2.1. This one is from an older version (3.1.4): . (The project for both was unchanged). Edit: Image URLS updated.

    Read the article

  • Windows 7 64 / Visual Studio 2008 / OpenCV2.1 error: "The application was unable to start correctly

    - by James
    Hey all, I'm building OpenCV2.1 from top of branch in 64 bit mode, when I link the libraries against my code (that works in 32 bit mode on XP), I get the dialog: "The application was unable to start correctly (0xc0150002) Click OK to close the application" When I start the application. The event viewer is pointing at one of the OpenCV dll's & says it's a Side-by-Side error, but I'm definitely building OpenCV & my code as a 64 bit compile, and there are no errors during that process. I've tried fiddling with the /MTd options & it doesn't help. Some (almost) related questions have suggested installing the VS2008 redistributable package, but I'm building using vs2008 pro, that seems like madness? Is it still necessary to install the package in my case? Any help, including the cause of these side-by-side errors, would be appreciated. James

    Read the article

  • Disable eclipselink caching and query caching - not working?

    - by James
    I am using eclipselink JPA with a database which is also being updated externally to my application. For that reason there are tables I want to query every few seconds. I can't get this to work even when I try to disable the cache and query cache. For example: EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("default"); EntityManager em = entityManagerFactory.createEntityManager(); MyLocation one = em.createNamedQuery("MyLocation.findMyLoc").getResultList().get(0); Thread.sleep(10000); MyLocation two = em.createNamedQuery("MyLocation.findMyLoc").getResultList().get(0); System.out.println(one.getCapacity() + " - " + two.getCapacity()); Even though the capacity changes while my application is sleeping the println always prints the same value for one and two. I have added the following to the persistence.xml <property name="eclipselink.cache.shared.default" value="false"/> <property name="eclipselink.query-results-cache" value="false"/> I must be missing something but am running out of ideas. James

    Read the article

  • iPhone Provisioning Profile problems...

    - by James
    I have already successfully submitted two apps to the app store, so I should be able to do it by now, right? With my most recent app, however, I'm having a bear of a time with getting the Application Identifier or Bundle Identifier set up. In my distribution profile, I have included the identifier "com.jmock.irowbeta", and then copied it exactly into the the app's Info.plist file under "Bundle Identifier". In the past, this has done the trick, but now I'm getting the error Provisioning profile 'irow beta' specificies the identifier 'com.jmock.irowbeta' which doesn't match the current setting 'com.yourcompany.irow-beta'. So it seems that its somehow still using the default of com.yourcompany.APPLICATION_NAME, but it shouldn't after I have changed it in the Info.plist, right? I think this means that xcode isn't recognizing that PLIST for some reason, because when I change the name of the icon file, for example, or other such attributes, nothing changes. If this is the problem, how do I make xcode recognize the PLIST? Otherwise, what the heck is going on? Thanks, James

    Read the article

  • Ninject - initialise objects

    - by James Lin
    Hi guys, I am new to ninject, I am wondering how I can run custom initizlisation code when constructing the injected objects? ie. I have a Sword class which implements IWeapon, but I want to pass an hit point value to the Sword class constructor, how do I achieve that? Do I need to write my own provider? A minor question, IKernel kernel = new StandardKernel(new Module1(), new Module2(), ...); what is the actual use of having multiple modules in Kernel? I sorta understand it, but could someone give me a formal explaination and use case? Thanks a lot! James

    Read the article

  • Setting an delegate for the UIDatePicker animation?

    - by james.ingham
    If I had a date picker within an action sheet and called the following line: [datePicker setDate:newDate animated:YES]; And then my app hides the action sheet the date picker is within, is there anyway to set up a animation delegate so that the user see's the animation of the date picker first and then hides the action sheet? I have done this with UIView's by calling: [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(METHOD)]; However I can not see anything like this for the date picker. Thanks in advanced - James

    Read the article

  • 100% height on nested table cell in IE

    - by James Cooper
    I want a nested table to expand to the height of the enclosing cell. This works as expected in Firefox/Chrome/Safari, but not in IE7 or IE8. Please see the example here: http://www.bitmechanic.com/heightDemo.html The DOCTYPE is relevant. While the demo above validates as HTML 4.01 Strict, it does not render properly in IE7. If I remove the DOCTYPE entirely, or set it to HTML 3.2, it renders properly in IE. Any suggestions on how to get this to render in 4.01 (strict or loose)? The actual web site is a bit more complicated -- changing the DOCTYPE will cause all sorts of other problems. We're struggling to understand the (presumed) IE bug here and how to work around it. thanks -- James

    Read the article

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