webdevRefinery Forum: Peppe - Viewing Profile - webdevRefinery Forum

Jump to content

Reputation: 5 Neutral
Group:
Members
Active Posts:
116 (0.15 per day)
Most Active In:
General Discussion (27 posts)
Joined:
24-March 11
Profile Views:
2419
Last Active:
User is offline Yesterday, 03:45 PM
Currently:
Offline

My Information

Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Male Male
Location:
Sweden

Contact Information

E-mail:
Private

Posts I've Made

  1. In Topic: Javascript Code Modularization

    13 January 2013 - 07:50 AM

    Maybe this is of interest: http://css-tricks.co...attern-edition/ the article also links to http://addyosmani.co...npatterns/book/
  2. In Topic: Formatting objects/classes from SOAP

    12 December 2012 - 05:40 AM

    Thank you Daniel and Sephern. Factory seems to be the way to go. Currently experimenting a bit with it.
  3. In Topic: Formatting objects/classes from SOAP

    11 December 2012 - 02:56 AM

    I'll rephrase.

    I have an array of Things.

    Each Thing has a Type and an Id property.

    The Type property is a String.

    I want to convert each Thing into its own class for ease of presentation.

    Any ideas on how to go about that except using a huge switch statement?


    public Thing[] things = new Thing[] {
        new Thing() { Type = "Color", Id = clr.Blue, Hex = #0000FF },
        new Thing() { Type = "Food", Id = food_Burger, Ingredients = new string[] { "Meat", "Lettuce", "Bread", "Ketchup"} }
    }
    
    List<Food> foods = new List<Food>();
    
    foreach(var thing in things)
    {
        if(thing.type.Equals("Food")
        {
           foods.add(thing);
        }
    }
    
  4. In Topic: Dynamic(?) Web service reference

    24 August 2012 - 03:47 AM

    The Web service just started working. So the provider has done something.
  5. In Topic: Insert using multiple contexts

    24 August 2012 - 03:46 AM

    View PostSephern, on 23 August 2012 - 01:18 PM, said:

    Something that might be worth doing is checking if those items already exist in your database with a little bit of linq. What is probably happening (obviously, I don't know your code so this is an assumption) is that you're getting items from the API which you've already cached in your applications database. Since you're trying to readd them you get primary key errors.



    Yes, they already exist so that's why I got the error. The problem was that I just wanted to create a many to many relationship between the new reservation and the department that already exists in the DB.


    I worked around the problem by creating a "APIEntity" class that holds all the data I got from the web service.
    When inserting a new Reservation, I create a new instance of the entity class Reservation and set some of the properties from the APIEntity class.
    In the APIEntity class I also have IDs of the departments for the reservation.
    So I get the Deparments from the database from those IDs and add it to the Reservation entity instance.
    Then SaveChanges().

Friends

Comments

Peppe has no profile comments yet. Why not say hello?


Enter your sign in name and password


Sign in options
  Or sign in with these services