小编Tim*_*çin的帖子

c#property get,设置不同的类型

我有这样的枚举和财产.

        public enum Type
        {
            Hourly = 1,
            Salary = 2,
            None = 3
        };


        public string EmployeeType
        {
            get
            {
                string type;
                switch (employeeType)
                {
                    case Type.Hourly:
                        type = "Hourly Employee";
                        break;
                    case Type.Salary:
                        type = "Salary Employee";
                        break;
                    default:
                        type = "None";
                        break;
                }
                return type;
            }

            // **EDIT:**
            // Now I am trying to parse the string as enum Type.
            // But Constructor still waits a string to set EmployeeType.
            set
            {
                employeeType = (Type)Enum.Parse(typeof(Type), value);
            } …
Run Code Online (Sandbox Code Playgroud)

c# get properties accessor set

5
推荐指数
1
解决办法
3万
查看次数

优化具有多个连接的SQL查询

我的数据库中有以下表格,我无法更改或修改.我保持Log表格简单但LogDetail与我的数据库中的相同.

记录表

 Id  User Department Service     Method

 21  John Sales      UserService GetUser
Run Code Online (Sandbox Code Playgroud)

LogDetail表

Id LogRef ParamName  ParamValue

30 21     FirstName  Adam
31 21     LastName   Smith     
32 21     Age        35
33 21     Gender     M
Run Code Online (Sandbox Code Playgroud)

现在,我正在使用以下查询来搜索谁(Adam,Smith,35,M)

SELECT 
L.*, D1.ParamName, D2.ParamName, D3.ParamName, D4.ParamName
FROM Log as L
INNER JOIN LogDetail as D1 on L.Id = D1.LogRef
INNER JOIN LogDetail as D2 on L.Id = D2.LogRef
INNER JOIN LogDetail as D3 on L.Id = D3.LogRef
INNER JOIN LogDetail as D4 …
Run Code Online (Sandbox Code Playgroud)

sql sql-server join query-optimization sql-server-2008-r2

3
推荐指数
1
解决办法
4198
查看次数

带有声明变量的 SQL Server charindex

我对 SQL SERVER 功能有一个简单的问题charindex

DECLARE @VAR1 varchar
SET @VAR1 = 'abcdef'
PRINT CHARINDEX('c', @VAR1)
Run Code Online (Sandbox Code Playgroud)

上面的语句应该打印3但打印0。为什么?

sql-server variables char

2
推荐指数
1
解决办法
4375
查看次数

Java autoboxing性能比较

    // Hideously slow program! Can you spot the object creation?
    Long sum = 0L;
    for (long i = 0; i < Integer.MAX_VALUE; i++) {
        sum += i;
    }
    end = System.currentTimeMillis();
    System.out.println("Long sum took: " + (end - start) + " milliseconds");

    long sum2 = 0L;
    for (long i = 0; i < Integer.MAX_VALUE; i++) {
        sum2 += i;
    }
    end = System.currentTimeMillis();
    System.out.println("long sum took: " + (end - start) + " milliseconds");
Run Code Online (Sandbox Code Playgroud)

嗨,我正在阅读有效的Java,并且Item 6:Avoid creating unnecessary objects …

java performance autoboxing

-1
推荐指数
1
解决办法
1606
查看次数