This project is read-only.

Why is the Id a string and not an int?

Jul 9, 2010 at 10:20 AM


is it easy to make it a int having the source code?


Jul 9, 2010 at 10:58 AM

Hi, Lisa!

The id is a string because a string can hold and other type. If your id is an int you can convert it to a string, the same is true for a DateTime or Guid. But it would not be true for int as the id type.

I do not recommend to change the lounge repo source to make the id type an int. It´s a feature sitting pretty deep down in the whole design.

What´s your problem with string as the id type?


PS: Instead of changing the basic type of ids we could think about making the lounge repo tolerant regarding the type of properties named "Id".

Jul 9, 2010 at 7:19 PM
Edited Jul 9, 2010 at 7:20 PM
scenario: Assume I want to get the highest value of a property CustomerID. Having a List<Customer> with many Customers. When I retrieve via LINQ the highest value of the CustomerID to get the LastAutoInc it needs a int not string. I want to get the last integer (id) of a customer in a customer list. After count +1 on it take that value assign it to a new customer object`s customerID and store that customer. With string that is a pain and I do not want to use Guid`s... terrible long and much space they take.
Jul 9, 2010 at 7:53 PM

@Lisa: You want to use Linq? Then look at this:

var max = new[] {"1", "88", "2", "10", "9"}.Max(s => int.Parse(s));

See how you can get the highest integer value from a list of strings representing integers?

I guess there is no need for an int id in the Lounge Repo. A string id is pretty much universal.


Jul 9, 2010 at 8:09 PM
ok you beat me :P yes it would be nice if I could use my own Id names :-)