PageRenderTime 27ms CodeModel.GetById 24ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/SimpleCrud/Types/LongType.cs

http://github.com/cordjr/simplecrud
C# | 41 lines | 30 code | 11 blank | 0 comment | 8 complexity | 13fd181fb9a3dc39ad54e124b4a1dac5 MD5 | raw file
 1using System;
 2using System.Data.Common;
 3using SimpleCrud.Core;
 4
 5
 6namespace SimpleCrud.Types {
 7    public class LongType : IDBType {
 8
 9        
10
11        public void BindToCommand(DbCommand cmd, int index, object value) {
12            if (value == null) {
13                cmd.Parameters[index].Value = DBNull.Value;
14            } else {
15                cmd.Parameters[index].Value = (long)value;
16            }
17        }
18
19        public void BindToCommand(DbCommand cmd, string paramName, object value) {
20            if (value == null) {
21                cmd.Parameters[paramName].Value = DBNull.Value;
22            } else {
23                cmd.Parameters[paramName].Value = (long)value;
24            }
25        }
26
27        public object GetFromDataReader(DbDataReader rset, int index) {
28            return rset.GetValue(index) == DBNull.Value ? 0 : rset.GetValue(index);
29        }
30
31        public object GetFromDataReader(DbDataReader rset, string fieldName) {
32            return rset[fieldName] == DBNull.Value ? 0 : rset[fieldName];
33        }
34
35        public Type GetImplType() {
36            return typeof (long);
37        }
38
39        
40    }
41}