DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Linq.DeveelDbExecutor Class Reference
Inheritance diagram for Deveel.Data.Linq.DeveelDbExecutor:

Classes

class  TableFieldReader
 

Public Member Functions

 DeveelDbExecutor (IQuery context)
 
override object Convert (object value, Type type)
 
override IEnumerable< T > Execute< T > (QueryCommand command, Func< FieldReader, T > fnProjector, MappingEntity entity, object[] paramValues)
 
override IEnumerable< int > ExecuteBatch (QueryCommand query, IEnumerable< object[]> paramSets, int batchSize, bool stream)
 
override IEnumerable< T > ExecuteBatch< T > (QueryCommand query, IEnumerable< object[]> paramSets, Func< FieldReader, T > fnProjector, MappingEntity entity, int batchSize, bool stream)
 
override IEnumerable< T > ExecuteDeferred< T > (QueryCommand command, Func< FieldReader, T > fnProjector, MappingEntity entity, object[] paramValues)
 
override int ExecuteCommand (QueryCommand query, object[] paramValues)
 

Properties

override int RowsAffected [get]
 

Private Member Functions

SqlQuery GetQuery (QueryCommand command, object[] paramValues)
 
void SetParameters (QueryCommand command, SqlQuery query, object[] paramValues)
 
void AddParameter (SqlQuery query, QueryParameter queryParameter, object value)
 
SqlType GetSqlType (Type type)
 
IEnumerable< T > Project< T > (ITable result, Func< FieldReader, T > fnProjector, MappingEntity entity)
 

Private Attributes

IQuery context
 
int rowsAffected
 

Detailed Description

Definition at line 17 of file DeveelDbExecutor.cs.

Constructor & Destructor Documentation

Deveel.Data.Linq.DeveelDbExecutor.DeveelDbExecutor ( IQuery  context)
inline

Definition at line 21 of file DeveelDbExecutor.cs.

21  {
22  this.context = context;
23  }

Member Function Documentation

void Deveel.Data.Linq.DeveelDbExecutor.AddParameter ( SqlQuery  query,
QueryParameter  queryParameter,
object  value 
)
inlineprivate

Definition at line 74 of file DeveelDbExecutor.cs.

74  {
75  var sqlType = GetSqlType(queryParameter.Type);
76  var param = new Sql.QueryParameter(queryParameter.Name, sqlType, (ISqlObject)value);
77  param.Direction = QueryParameterDirection.In;
78  query.Parameters.Add(param);
79  }
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
ICollection< QueryParameter > Parameters
Definition: SqlQuery.cs:53
override object Deveel.Data.Linq.DeveelDbExecutor.Convert ( object  value,
Type  type 
)
inline

Definition at line 25 of file DeveelDbExecutor.cs.

25  {
26  if (value == null) {
27  return TypeHelper.GetDefault(type);
28  }
29 
30  type = TypeHelper.GetNonNullableType(type);
31  var vtype = value.GetType();
32 
33  if (type != vtype) {
34  if (type.IsEnum) {
35  if (vtype == typeof (string))
36  return Enum.Parse(type, (string) value);
37 
38  Type utype = Enum.GetUnderlyingType(type);
39  if (utype != vtype)
40  value = System.Convert.ChangeType(value, utype);
41 
42  return Enum.ToObject(type, value);
43  }
44 
45  return System.Convert.ChangeType(value, type);
46  }
47 
48  return value;
49  }
A user-defined TYPE that holds complex objects in a database column.
override IEnumerable<T> Deveel.Data.Linq.DeveelDbExecutor.Execute< T > ( QueryCommand  command,
Func< FieldReader, T >  fnProjector,
MappingEntity  entity,
object[]  paramValues 
)
inline

Definition at line 85 of file DeveelDbExecutor.cs.

85  {
86  var query = GetQuery(command, paramValues);
87  var queryResult = context.ExecuteQuery(query);
88 
89  return Project(queryResult[0], fnProjector, entity);
90  }
SqlQuery GetQuery(QueryCommand command, object[] paramValues)
override IEnumerable<int> Deveel.Data.Linq.DeveelDbExecutor.ExecuteBatch ( QueryCommand  query,
IEnumerable< object[]>  paramSets,
int  batchSize,
bool  stream 
)
inline

Definition at line 99 of file DeveelDbExecutor.cs.

99  {
100  throw new NotImplementedException();
101  }
override IEnumerable<T> Deveel.Data.Linq.DeveelDbExecutor.ExecuteBatch< T > ( QueryCommand  query,
IEnumerable< object[]>  paramSets,
Func< FieldReader, T >  fnProjector,
MappingEntity  entity,
int  batchSize,
bool  stream 
)
inline

Definition at line 103 of file DeveelDbExecutor.cs.

104  {
105  throw new NotImplementedException();
106  }
override int Deveel.Data.Linq.DeveelDbExecutor.ExecuteCommand ( QueryCommand  query,
object[]  paramValues 
)
inline

Definition at line 115 of file DeveelDbExecutor.cs.

115  {
116  var sqlQuery = GetQuery(query, paramValues);
117  var result = context.ExecuteQuery(sqlQuery);
118  rowsAffected = result[0].RowCount;
119  return rowsAffected;
120  }
SqlQuery GetQuery(QueryCommand command, object[] paramValues)
override IEnumerable<T> Deveel.Data.Linq.DeveelDbExecutor.ExecuteDeferred< T > ( QueryCommand  command,
Func< FieldReader, T >  fnProjector,
MappingEntity  entity,
object[]  paramValues 
)
inline

Definition at line 108 of file DeveelDbExecutor.cs.

108  {
109  var query = GetQuery(command, paramValues);
110  var queryResult = context.ExecuteQuery(query);
111 
112  return Project(queryResult[0], fnProjector, entity);
113  }
SqlQuery GetQuery(QueryCommand command, object[] paramValues)
SqlQuery Deveel.Data.Linq.DeveelDbExecutor.GetQuery ( QueryCommand  command,
object[]  paramValues 
)
inlineprivate

Definition at line 51 of file DeveelDbExecutor.cs.

51  {
52  var query = new SqlQuery(command.CommandText);
53  SetParameters(command, query, paramValues);
54  return query;
55  }
void SetParameters(QueryCommand command, SqlQuery query, object[] paramValues)
SqlType Deveel.Data.Linq.DeveelDbExecutor.GetSqlType ( Type  type)
inlineprivate

Definition at line 81 of file DeveelDbExecutor.cs.

81  {
82  throw new NotImplementedException();
83  }
IEnumerable<T> Deveel.Data.Linq.DeveelDbExecutor.Project< T > ( ITable  result,
Func< FieldReader, T >  fnProjector,
MappingEntity  entity 
)
inlineprivate

Definition at line 92 of file DeveelDbExecutor.cs.

92  {
93  var reader = new TableFieldReader(result);
94  while (reader.NextRow()) {
95  yield return fnProjector(reader);
96  }
97  }
void Deveel.Data.Linq.DeveelDbExecutor.SetParameters ( QueryCommand  command,
SqlQuery  query,
object[]  paramValues 
)
inlineprivate

Definition at line 57 of file DeveelDbExecutor.cs.

57  {
58  if (command.Parameters.Count > 0 && query.Parameters.Count == 0) {
59  for (int i = 0, n = command.Parameters.Count; i < n; i++) {
60  AddParameter(query, command.Parameters[i], paramValues != null ? paramValues[i] : null);
61  }
62  } else if (paramValues != null) {
63  var queryParams = query.Parameters.ToList();
64  for (int i = 0, n = queryParams.Count; i < n; i++) {
65  var p = queryParams[i];
66  if (p.Direction == QueryParameterDirection.In
67  || p.Direction == QueryParameterDirection.InOut) {
68  p.Value = (ISqlObject) paramValues[i] ?? SqlNull.Value;
69  }
70  }
71  }
72  }
static readonly SqlNull Value
Definition: SqlNull.cs:24
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
void AddParameter(SqlQuery query, QueryParameter queryParameter, object value)
ICollection< QueryParameter > Parameters
Definition: SqlQuery.cs:53

Member Data Documentation

IQuery Deveel.Data.Linq.DeveelDbExecutor.context
private

Definition at line 18 of file DeveelDbExecutor.cs.

int Deveel.Data.Linq.DeveelDbExecutor.rowsAffected
private

Definition at line 19 of file DeveelDbExecutor.cs.

Property Documentation

override int Deveel.Data.Linq.DeveelDbExecutor.RowsAffected
get

Definition at line 122 of file DeveelDbExecutor.cs.


The documentation for this class was generated from the following file: