1. Список говнокодов пользователя _volt

    Всего: 1

  2. C# / Говнокод #5263

    +127

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    public IQueryable<AuditEntry> ViewAudit()
    {
    	var items = _operationEntities.AuditItems.AsQueryable();
    
    	return items.Select((item) => new AuditEntry()
    	{
    		OperationID = item.Id,
    		CreationTime = item.CreationTime,
             
    		Description = item.AuditItemType.StringFormat.Replace(
    			"{0}", item.InsertionStrings.Where((x) => x.StringId == 0).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{1}", item.InsertionStrings.Where((x) => x.StringId == 1).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{2}", item.InsertionStrings.Where((x) => x.StringId == 2).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{3}", item.InsertionStrings.Where((x) => x.StringId == 3).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{4}", item.InsertionStrings.Where((x) => x.StringId == 4).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{5}", item.InsertionStrings.Where((x) => x.StringId == 5).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{6}", item.InsertionStrings.Where((x) => x.StringId == 6).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{7}", item.InsertionStrings.Where((x) => x.StringId == 7).Select((x) => x.String).FirstOrDefault() ?? String.Empty),
                    
    		CreatedBy = item.CreatedBy,
    		OperationType = item.AuditItemType.MessageType.Name,
    		OperationCategory = item.AuditItemType.AuditCategory.Name,
    	});
    }

    Паровозик. Реализация string.Format() в виде linq-запроса

    _volt, 13 Января 2011

    Комментарии (2)