« first day (3168 days earlier)      last day (1766 days later) » 

user10864482
9:00 PM
At some point, when your db will become more complex you might want to have a look at Entity. With that framework you can generate model from your database structure and limit the amount of code you need to write to interact with the db
 
I think Sam's already using EF
 
user10864482
great, srry
 
user10864482
@SamuelWakeman to learn new stuff is almost always painful but as programmer, we will always need to learn new stuff; to become better, because stuff expire fast and because it's the nature of our field; that is technology evolve so fast. What you are feeling is normal; its uncomfortable but fight it; you will be rewarded
 
user10864482
g'night everyone, i'm off
 
some of the stuff you have to learn is easy, like whatever the database or javascript flavor of the month is
the things that take longer to learn- structuring programs correctly, reasoning about programs, how the machine works under the covers- will never change and serve you well for the rest of your life
 
9:12 PM
hi, i have a List ob public static objects. when i take one and modify the properties, also the properties in the list are updated. how i can make a copy of the object?
 
typically you don't- copying an object is a real pain
think about what you're trying to do here
 
simple example:
var o = MyList.FirstOrDefault(x=> x.Id == 1);
o.Id = 2;
//becomes true
MyList.FirstOrDefault(x=> x.Id == 1) == null
 
Sure, I understand the semantics at play here
but what are you trying to do in your program
why is this behavior not what you want
 
in my case it makes sense (for me..). the objects are cached from a DB. it's a MVC website. each user can have a different price of the same object. so i get the item by id and set the individual price of the user
so in the user db i only have to save the itemId and the price and not the whole object with all data
so the default price gets overwritten
 
sounds like what you want to do is have a UserPrice that you make from the database price or some such
 
9:20 PM
yep basically i'm merging two informations into one
 
like, have two separate objects
 
correct :)
 
new UserPrice(int itemId, decimal price)
and so now you don't have to change the DatabasePrice
 
hmmm the itemid has around 30 properties so i have to write 30 lines of code for that?
the item object i mean :)
 
well, you only need to change the things that change, right
you could have your user object hold the database object plus the user price
 
9:23 PM
sorry i get confused. then i automatically change the cached object
 
You only want to maintain a different price for the user, right
everything else is the same as in the databse?
 
to be honest a little bit more. but i dont find a way around it to assign all properties to avoid that my cache gets overwritten
 
class UserItem
{
     decimal UserPrice {get;}
     DatabaseItem DbItem {get;}

     UserItem(decimal userPrice, DatabaseItem database)
     {
         UserPrice = userPrice; DbItem = database;
     }
}
don't go changing the database item, then
like, you sound like you're doing a shopping type thing, right
why go around changing the database items
 
okay i see :(
 
I'm trying to help you, buddy, what's with the frowny face
 
9:30 PM
sorry grace :) i understand your point and you are right that it's a bad style too to have a cached db object which should be modified and mixed with other data
 
Hope it helps.
 
but in my case it can not work and the logic makes sense in this specific case.
 
I don't believe you, but okay.
 
no problem. when you are interested, i can try to explain it
 
10:09 PM
thank you anyways. i appreciate it
 

« first day (3168 days earlier)      last day (1766 days later) »