Polecam

.NET Blogs PL
CodeGuru


Już Piątek: LINQ to the rescue!

April 1, 2011 in categories: pro by Gutek

4

Kod z produkcji...

StepObject newObject = null;
if ((currentObjects
        .Where(
            o => o.GetType()
                  .GetProperties()
                  .Where(t => t.Name == "INT32")
                  .First()
                  .GetValue(o, null)
                  .ToString() 
                ==
                currentObject.GetType()
                    .GetProperties()
                    .Where(t => t.Name == "INT32")
                    .First()
                    .GetValue(currentObject, null)
                    .ToString()
        ).Count() > 0))
{
    newObject = currentObjects.Where(
                    o => o.GetType()
                          .GetProperties()
                          .Where(t => t.Name == "INT32")
                          .First()
                          .GetValue(o, null)
                          .ToString() 
                        ==
                        currentObject.GetType()
                            .GetProperties()
                            .Where(t => t.Name == "INT32")
                            .First()
                            .GetValue(currentObject, null)
                            .ToString()
                ).First();

    if (newObject.State.Equals(WorkStates.Approved))
        newObject = (currentObject.GetType()
                        .GetConstructor(new Type[0])
                        .Invoke(new object[0]) as StepObject);
}
else
{
   // removed for clarity
}



 

 

 

4 comments for "Już Piątek: LINQ to the rescue!"

  1. Procent
    Procent Says:

    haha, dobre:

    // removed for clarity

    Smile

  2. Bartek
    Bartek Says:

    A nie można było FirstOrDefault? Smile

    • Gutek
      Gutek Says:

      mozna bylo duzo rzeczy zrobic, ale jak widac nie zostaly zrobione Smile dlaczego? nie wiem Smile mnie sie nie pytaj - nie ja to pisalem Smile

  3. łukasz
    łukasz Says:

    hahaha o masakra Laughing dzięki za to że mogłem się pośmiać! Laughing

Comments are closed

© 2008-2010 Jakub Gutkowski. Powered by BlogEngine.NET 1.5.1.14. Hosted on OrcsWeb.

Design