removed redundant qualifiers.

pull/24/head
kay.one 11 years ago
parent 50f66cbcca
commit e89a35522e

@ -14,10 +14,12 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Globalization;
using Marr.Data.Mapping;
namespace Marr.Data.Converters namespace Marr.Data.Converters
{ {
public class CastConverter<TClr, TDb> : Marr.Data.Converters.IConverter public class CastConverter<TClr, TDb> : IConverter
where TClr : IConvertible where TClr : IConvertible
where TDb : IConvertible where TDb : IConvertible
{ {
@ -28,16 +30,16 @@ namespace Marr.Data.Converters
get { return typeof(TDb); } get { return typeof(TDb); }
} }
public object FromDB(Marr.Data.Mapping.ColumnMap map, object dbValue) public object FromDB(ColumnMap map, object dbValue)
{ {
TDb val = (TDb)dbValue; TDb val = (TDb)dbValue;
return val.ToType(typeof(TClr), System.Globalization.CultureInfo.InvariantCulture); return val.ToType(typeof(TClr), CultureInfo.InvariantCulture);
} }
public object ToDB(object clrValue) public object ToDB(object clrValue)
{ {
TClr val = (TClr)clrValue; TClr val = (TClr)clrValue;
return val.ToType(typeof(TDb), System.Globalization.CultureInfo.InvariantCulture); return val.ToType(typeof(TDb), CultureInfo.InvariantCulture);
} }
#endregion #endregion

@ -131,7 +131,7 @@ namespace Marr.Data
if (parameter.Value == null) if (parameter.Value == null)
parameter.Value = DBNull.Value; parameter.Value = DBNull.Value;
this.Parameters.Add(parameter); Parameters.Add(parameter);
return parameter; return parameter;
} }
@ -395,7 +395,7 @@ namespace Marr.Data
public int InsertDataTable(DataTable table, string insertSP) public int InsertDataTable(DataTable table, string insertSP)
{ {
return this.InsertDataTable(table, insertSP, UpdateRowSource.None); return InsertDataTable(table, insertSP, UpdateRowSource.None);
} }
public int InsertDataTable(DataTable dt, string sql, UpdateRowSource updateRowSource) public int InsertDataTable(DataTable dt, string sql, UpdateRowSource updateRowSource)
@ -462,7 +462,7 @@ namespace Marr.Data
public T Find<T>(string sql) public T Find<T>(string sql)
{ {
return this.Find<T>(sql, default(T)); return Find<T>(sql, default(T));
} }
/// <summary> /// <summary>
@ -526,7 +526,7 @@ namespace Marr.Data
/// <returns>Returns a QueryBuilder of T.</returns> /// <returns>Returns a QueryBuilder of T.</returns>
public QueryBuilder<T> Query<T>() public QueryBuilder<T> Query<T>()
{ {
var dialect = QGen.QueryFactory.CreateDialect(this); var dialect = QueryFactory.CreateDialect(this);
return new QueryBuilder<T>(this, dialect); return new QueryBuilder<T>(this, dialect);
} }
@ -783,7 +783,7 @@ namespace Marr.Data
public int Delete<T>(string tableName, Expression<Func<T, bool>> filter) public int Delete<T>(string tableName, Expression<Func<T, bool>> filter)
{ {
// Remember sql mode // Remember sql mode
var previousSqlMode = this.SqlMode; var previousSqlMode = SqlMode;
SqlMode = SqlModes.Text; SqlMode = SqlModes.Text;
var mappingHelper = new MappingHelper(this); var mappingHelper = new MappingHelper(this);
@ -791,7 +791,7 @@ namespace Marr.Data
{ {
tableName = MapRepository.Instance.GetTableName(typeof(T)); tableName = MapRepository.Instance.GetTableName(typeof(T));
} }
var dialect = QGen.QueryFactory.CreateDialect(this); var dialect = QueryFactory.CreateDialect(this);
TableCollection tables = new TableCollection(); TableCollection tables = new TableCollection();
tables.Add(new Table(typeof(T))); tables.Add(new Table(typeof(T)));
var where = new WhereBuilder<T>(Command, dialect, filter, tables, false, false); var where = new WhereBuilder<T>(Command, dialect, filter, tables, false, false);

@ -84,7 +84,7 @@ namespace Marr.Data
} }
// Create a new EntityGraph for each child relationship that is not lazy loaded // Create a new EntityGraph for each child relationship that is not lazy loaded
foreach (Relationship childRelationship in this.Relationships) foreach (Relationship childRelationship in Relationships)
{ {
if (!childRelationship.IsLazyLoaded) if (!childRelationship.IsLazyLoaded)
{ {
@ -169,7 +169,7 @@ namespace Marr.Data
_entity = entityInstance; _entity = entityInstance;
// Add newly created entityInstance to list (Many) or set it to field (One) // Add newly created entityInstance to list (Many) or set it to field (One)
if (this.IsRoot) if (IsRoot)
{ {
RootList.Add(entityInstance); RootList.Add(entityInstance);
} }
@ -213,7 +213,7 @@ namespace Marr.Data
bool isNewGroup = false; bool isNewGroup = false;
// Get primary keys from parent entity and any one-to-one child entites // Get primary keys from parent entity and any one-to-one child entites
GroupingKeyCollection groupingKeyColumns = this.GroupingKeyColumns; GroupingKeyCollection groupingKeyColumns = GroupingKeyColumns;
// Concatenate column values // Concatenate column values
KeyGroupInfo keyGroupInfo = groupingKeyColumns.CreateGroupingKey(reader); KeyGroupInfo keyGroupInfo = groupingKeyColumns.CreateGroupingKey(reader);
@ -265,7 +265,7 @@ namespace Marr.Data
private object FindParentReference() private object FindParentReference()
{ {
var parent = this.Parent.Parent; var parent = Parent.Parent;
while (parent != null) while (parent != null)
{ {
if (parent._entityType == _relationship.MemberType) if (parent._entityType == _relationship.MemberType)
@ -333,7 +333,7 @@ namespace Marr.Data
// * Only 1-1 entities with no children are allowed to have 0 PKs specified. // * Only 1-1 entities with no children are allowed to have 0 PKs specified.
if ((groupingKeyColumns.PrimaryKeys.Count == 0 && _children.Count > 0) || if ((groupingKeyColumns.PrimaryKeys.Count == 0 && _children.Count > 0) ||
(groupingKeyColumns.PrimaryKeys.Count == 0 && !IsRoot && _relationship.RelationshipInfo.RelationType == RelationshipTypes.Many)) (groupingKeyColumns.PrimaryKeys.Count == 0 && !IsRoot && _relationship.RelationshipInfo.RelationType == RelationshipTypes.Many))
throw new MissingPrimaryKeyException(string.Format("There are no primary key mappings defined for the following entity: '{0}'.", this.EntityType.Name)); throw new MissingPrimaryKeyException(string.Format("There are no primary key mappings defined for the following entity: '{0}'.", EntityType.Name));
// Add parent's keys // Add parent's keys
if (IsChild) if (IsChild)
@ -378,7 +378,7 @@ namespace Marr.Data
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return this.GetEnumerator(); return GetEnumerator();
} }
#endregion #endregion

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Marr.Data.Mapping; using Marr.Data.Mapping;
@ -74,9 +75,9 @@ namespace Marr.Data
#region IEnumerable Members #region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return this.GetEnumerator(); return GetEnumerator();
} }
#endregion #endregion

@ -53,10 +53,10 @@ namespace Marr.Data
ReflectionStrategy = new SimpleReflectionStrategy(); ReflectionStrategy = new SimpleReflectionStrategy();
// Register a default type converter for Enums // Register a default type converter for Enums
TypeConverters.Add(typeof(Enum), new Converters.EnumStringConverter()); TypeConverters.Add(typeof(Enum), new EnumStringConverter());
// Register a default IDbTypeBuilder // Register a default IDbTypeBuilder
_dbTypeBuilder = new Parameters.DbTypeBuilder(); _dbTypeBuilder = new DbTypeBuilder();
_columnMapStrategies = new Dictionary<Type, IMapStrategy>(); _columnMapStrategies = new Dictionary<Type, IMapStrategy>();
RegisterDefaultMapStrategy(new AttributeMapStrategy()); RegisterDefaultMapStrategy(new AttributeMapStrategy());

@ -1,4 +1,6 @@
namespace Marr.Data.Mapping using System.Data;
namespace Marr.Data.Mapping
{ {
public class ColumnInfo : IColumnInfo public class ColumnInfo : IColumnInfo
{ {
@ -7,7 +9,7 @@
IsPrimaryKey = false; IsPrimaryKey = false;
IsAutoIncrement = false; IsAutoIncrement = false;
ReturnValue = false; ReturnValue = false;
ParamDirection = System.Data.ParameterDirection.Input; ParamDirection = ParameterDirection.Input;
} }
public string Name { get; set; } public string Name { get; set; }
@ -16,7 +18,7 @@
public bool IsPrimaryKey { get; set; } public bool IsPrimaryKey { get; set; }
public bool IsAutoIncrement { get; set; } public bool IsAutoIncrement { get; set; }
public bool ReturnValue { get; set; } public bool ReturnValue { get; set; }
public System.Data.ParameterDirection ParamDirection { get; set; } public ParameterDirection ParamDirection { get; set; }
public string TryGetAltName() public string TryGetAltName()
{ {

@ -30,12 +30,12 @@ namespace Marr.Data.Mapping
public ColumnMap GetByColumnName(string columnName) public ColumnMap GetByColumnName(string columnName)
{ {
return this.Find(m => m.ColumnInfo.Name == columnName); return Find(m => m.ColumnInfo.Name == columnName);
} }
public ColumnMap GetByFieldName(string fieldName) public ColumnMap GetByFieldName(string fieldName)
{ {
return this.Find(m => m.FieldName == fieldName); return Find(m => m.FieldName == fieldName);
} }
/// <summary> /// <summary>
@ -107,7 +107,7 @@ namespace Marr.Data.Mapping
/// <returns>A list of mapped columns that are present in the sql statement as parameters.</returns> /// <returns>A list of mapped columns that are present in the sql statement as parameters.</returns>
public ColumnMapCollection OrderParameters(DbCommand command) public ColumnMapCollection OrderParameters(DbCommand command)
{ {
if (command.CommandType == CommandType.Text && this.Count > 0) if (command.CommandType == CommandType.Text && Count > 0)
{ {
string commandTypeString = command.GetType().ToString(); string commandTypeString = command.GetType().ToString();
if (commandTypeString.Contains("Oracle") || commandTypeString.Contains("OleDb")) if (commandTypeString.Contains("Oracle") || commandTypeString.Contains("OleDb"))
@ -120,7 +120,7 @@ namespace Marr.Data.Mapping
Regex regex = new Regex(regexString); Regex regex = new Regex(regexString);
foreach (Match m in regex.Matches(command.CommandText)) foreach (Match m in regex.Matches(command.CommandText))
{ {
ColumnMap matchingColumn = this.Find(c => string.Concat(paramPrefix, c.ColumnInfo.Name.ToLower()) == m.Value.ToLower()); ColumnMap matchingColumn = Find(c => string.Concat(paramPrefix, c.ColumnInfo.Name.ToLower()) == m.Value.ToLower());
if (matchingColumn != null) if (matchingColumn != null)
columns.Add(matchingColumn); columns.Add(matchingColumn);
} }
@ -148,7 +148,7 @@ namespace Marr.Data.Mapping
/// <returns></returns> /// <returns></returns>
public ColumnMapCollection PrefixAltNames(string prefix) public ColumnMapCollection PrefixAltNames(string prefix)
{ {
this.ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name.Insert(0, prefix)); ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name.Insert(0, prefix));
return this; return this;
} }
@ -163,7 +163,7 @@ namespace Marr.Data.Mapping
/// <returns></returns> /// <returns></returns>
public ColumnMapCollection SuffixAltNames(string suffix) public ColumnMapCollection SuffixAltNames(string suffix)
{ {
this.ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name + suffix); ForEach(c => c.ColumnInfo.AltName = c.ColumnInfo.Name + suffix);
return this; return this;
} }

@ -55,9 +55,9 @@ namespace Marr.Data.Mapping
public class MappingsFluentColumns<TEntity> public class MappingsFluentColumns<TEntity>
{ {
private bool _publicOnly; private bool _publicOnly;
private FluentMappings.MappingsFluentEntity<TEntity> _fluentEntity; private MappingsFluentEntity<TEntity> _fluentEntity;
public MappingsFluentColumns(FluentMappings.MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly) public MappingsFluentColumns(MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly)
{ {
_fluentEntity = fluentEntity; _fluentEntity = fluentEntity;
_publicOnly = publicOnly; _publicOnly = publicOnly;
@ -122,9 +122,9 @@ namespace Marr.Data.Mapping
public class MappingsFluentTables<TEntity> public class MappingsFluentTables<TEntity>
{ {
private FluentMappings.MappingsFluentEntity<TEntity> _fluentEntity; private MappingsFluentEntity<TEntity> _fluentEntity;
public MappingsFluentTables(FluentMappings.MappingsFluentEntity<TEntity> fluentEntity) public MappingsFluentTables(MappingsFluentEntity<TEntity> fluentEntity)
{ {
_fluentEntity = fluentEntity; _fluentEntity = fluentEntity;
} }
@ -152,10 +152,10 @@ namespace Marr.Data.Mapping
public class MappingsFluentRelationships<TEntity> public class MappingsFluentRelationships<TEntity>
{ {
private FluentMappings.MappingsFluentEntity<TEntity> _fluentEntity; private MappingsFluentEntity<TEntity> _fluentEntity;
private bool _publicOnly; private bool _publicOnly;
public MappingsFluentRelationships(FluentMappings.MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly) public MappingsFluentRelationships(MappingsFluentEntity<TEntity> fluentEntity, bool publicOnly)
{ {
_fluentEntity = fluentEntity; _fluentEntity = fluentEntity;
_publicOnly = publicOnly; _publicOnly = publicOnly;

@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Collections;
using System.Reflection; using System.Reflection;
using Marr.Data.Reflection; using Marr.Data.Reflection;
@ -35,7 +36,7 @@ namespace Marr.Data.Mapping
// Try to determine the RelationshipType // Try to determine the RelationshipType
if (relationshipInfo.RelationType == RelationshipTypes.AutoDetect) if (relationshipInfo.RelationType == RelationshipTypes.AutoDetect)
{ {
if (typeof(System.Collections.ICollection).IsAssignableFrom(MemberType)) if (typeof(ICollection).IsAssignableFrom(MemberType))
{ {
relationshipInfo.RelationType = RelationshipTypes.Many; relationshipInfo.RelationType = RelationshipTypes.Many;
} }

@ -28,7 +28,7 @@ namespace Marr.Data.Mapping
{ {
get get
{ {
return this.Find(m => m.Member.Name == fieldName); return Find(m => m.Member.Name == fieldName);
} }
} }
} }

@ -27,7 +27,7 @@ namespace Marr.Data.Mapping.Strategies
protected override void CreateColumnMap(Type entityType, System.Reflection.MemberInfo member, ColumnAttribute columnAtt, ColumnMapCollection columnMaps) protected override void CreateColumnMap(Type entityType, MemberInfo member, ColumnAttribute columnAtt, ColumnMapCollection columnMaps)
{ {
if (ColumnPredicate(member)) if (ColumnPredicate(member))
{ {
@ -36,7 +36,7 @@ namespace Marr.Data.Mapping.Strategies
} }
} }
protected override void CreateRelationship(Type entityType, System.Reflection.MemberInfo member, RelationshipAttribute relationshipAtt, RelationshipCollection relationships) protected override void CreateRelationship(Type entityType, MemberInfo member, RelationshipAttribute relationshipAtt, RelationshipCollection relationships)
{ {
if (RelationshipPredicate(member)) if (RelationshipPredicate(member))
{ {

@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Collections;
using System.Reflection; using System.Reflection;
namespace Marr.Data.Mapping.Strategies namespace Marr.Data.Mapping.Strategies
@ -70,7 +71,7 @@ namespace Marr.Data.Mapping.Strategies
if (member.MemberType == MemberTypes.Property) if (member.MemberType == MemberTypes.Property)
{ {
PropertyInfo propertyInfo = member as PropertyInfo; PropertyInfo propertyInfo = member as PropertyInfo;
if (typeof(System.Collections.ICollection).IsAssignableFrom(propertyInfo.PropertyType)) if (typeof(ICollection).IsAssignableFrom(propertyInfo.PropertyType))
{ {
Relationship relationship = new Relationship(member); Relationship relationship = new Relationship(member);
relationships.Add(relationship); relationships.Add(relationship);

@ -62,7 +62,7 @@ namespace Marr.Data.Parameters
return DbType.Object; return DbType.Object;
} }
public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) public void SetDbType(IDbDataParameter param, Enum dbType)
{ {
param.DbType = (DbType)dbType; param.DbType = (DbType)dbType;
} }

@ -14,6 +14,7 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>. */ License along with this library. If not, see <http://www.gnu.org/licenses/>. */
using System; using System;
using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
namespace Marr.Data.Parameters namespace Marr.Data.Parameters
@ -59,7 +60,7 @@ namespace Marr.Data.Parameters
return OleDbType.Variant; return OleDbType.Variant;
} }
public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) public void SetDbType(IDbDataParameter param, Enum dbType)
{ {
var oleDbParam = (OleDbParameter)param; var oleDbParam = (OleDbParameter)param;
oleDbParam.OleDbType = (OleDbType)dbType; oleDbParam.OleDbType = (OleDbType)dbType;

@ -63,7 +63,7 @@ namespace Marr.Data.Parameters
return SqlDbType.Variant; return SqlDbType.Variant;
} }
public void SetDbType(System.Data.IDbDataParameter param, Enum dbType) public void SetDbType(IDbDataParameter param, Enum dbType)
{ {
var sqlDbParam = (SqlParameter)param; var sqlDbParam = (SqlParameter)param;
sqlDbParam.SqlDbType = (SqlDbType)dbType; sqlDbParam.SqlDbType = (SqlDbType)dbType;

@ -1,4 +1,6 @@
namespace Marr.Data.QGen using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen
{ {
/// <summary> /// <summary>
/// This class creates a SQL delete query. /// This class creates a SQL delete query.
@ -7,9 +9,9 @@
{ {
protected Table TargetTable { get; set; } protected Table TargetTable { get; set; }
protected string WhereClause { get; set; } protected string WhereClause { get; set; }
protected Dialects.Dialect Dialect { get; set; } protected Dialect Dialect { get; set; }
public DeleteQuery(Dialects.Dialect dialect, Table targetTable, string whereClause) public DeleteQuery(Dialect dialect, Table targetTable, string whereClause)
{ {
Dialect = dialect; Dialect = dialect;
TargetTable = targetTable; TargetTable = targetTable;

@ -35,7 +35,7 @@ namespace Marr.Data.QGen
case ExpressionType.Not: case ExpressionType.Not:
case ExpressionType.Quote: case ExpressionType.Quote:
case ExpressionType.TypeAs: case ExpressionType.TypeAs:
return this.VisitUnary((UnaryExpression)expression); return VisitUnary((UnaryExpression)expression);
case ExpressionType.Add: case ExpressionType.Add:
case ExpressionType.AddChecked: case ExpressionType.AddChecked:
case ExpressionType.And: case ExpressionType.And:
@ -60,15 +60,15 @@ namespace Marr.Data.QGen
case ExpressionType.RightShift: case ExpressionType.RightShift:
case ExpressionType.Subtract: case ExpressionType.Subtract:
case ExpressionType.SubtractChecked: case ExpressionType.SubtractChecked:
return this.VisitBinary((BinaryExpression)expression); return VisitBinary((BinaryExpression)expression);
case ExpressionType.Call: case ExpressionType.Call:
return this.VisitMethodCall((MethodCallExpression)expression); return VisitMethodCall((MethodCallExpression)expression);
case ExpressionType.Constant: case ExpressionType.Constant:
return this.VisitConstant((ConstantExpression)expression); return VisitConstant((ConstantExpression)expression);
case ExpressionType.MemberAccess: case ExpressionType.MemberAccess:
return this.VisitMemberAccess((MemberExpression)expression); return VisitMemberAccess((MemberExpression)expression);
case ExpressionType.Parameter: case ExpressionType.Parameter:
return this.VisitParameter((ParameterExpression)expression); return VisitParameter((ParameterExpression)expression);
} }
throw new ArgumentOutOfRangeException("expression", expression.NodeType.ToString()); throw new ArgumentOutOfRangeException("expression", expression.NodeType.ToString());
@ -111,8 +111,8 @@ namespace Marr.Data.QGen
/// <returns></returns> /// <returns></returns>
protected virtual Expression VisitBinary(BinaryExpression expression) protected virtual Expression VisitBinary(BinaryExpression expression)
{ {
this.Visit(expression.Left); Visit(expression.Left);
this.Visit(expression.Right); Visit(expression.Right);
return expression; return expression;
} }
@ -123,7 +123,7 @@ namespace Marr.Data.QGen
/// <returns></returns> /// <returns></returns>
protected virtual Expression VisitUnary(UnaryExpression expression) protected virtual Expression VisitUnary(UnaryExpression expression)
{ {
this.Visit(expression.Operand); Visit(expression.Operand);
return expression; return expression;
} }
@ -134,7 +134,7 @@ namespace Marr.Data.QGen
/// <returns></returns> /// <returns></returns>
protected virtual Expression VisitLamda(LambdaExpression lambdaExpression) protected virtual Expression VisitLamda(LambdaExpression lambdaExpression)
{ {
this.Visit(lambdaExpression.Body); Visit(lambdaExpression.Body);
return lambdaExpression; return lambdaExpression;
} }

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Marr.Data.Mapping; using Marr.Data.Mapping;
using System.Linq.Expressions; using System.Linq.Expressions;
using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
{ {
@ -15,7 +16,7 @@ namespace Marr.Data.QGen
private SqlModes _previousSqlMode; private SqlModes _previousSqlMode;
private bool _generateQuery = true; private bool _generateQuery = true;
private bool _getIdentityValue; private bool _getIdentityValue;
private Dialects.Dialect _dialect; private Dialect _dialect;
private ColumnMapCollection _columnsToInsert; private ColumnMapCollection _columnsToInsert;
public InsertQueryBuilder() public InsertQueryBuilder()

@ -6,6 +6,7 @@ using System.Reflection;
using Marr.Data.Mapping; using Marr.Data.Mapping;
using System.Data.Common; using System.Data.Common;
using System.Collections; using System.Collections;
using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
{ {
@ -19,7 +20,7 @@ namespace Marr.Data.QGen
#region - Private Members - #region - Private Members -
private DataMapper _db; private DataMapper _db;
private Dialects.Dialect _dialect; private Dialect _dialect;
private TableCollection _tables; private TableCollection _tables;
private WhereBuilder<T> _whereBuilder; private WhereBuilder<T> _whereBuilder;
private SortBuilder<T> _sortBuilder; private SortBuilder<T> _sortBuilder;
@ -71,7 +72,7 @@ namespace Marr.Data.QGen
// Used only for unit testing with mock frameworks // Used only for unit testing with mock frameworks
} }
public QueryBuilder(DataMapper db, Dialects.Dialect dialect) public QueryBuilder(DataMapper db, Dialect dialect)
{ {
_db = db; _db = db;
_dialect = dialect; _dialect = dialect;
@ -499,7 +500,7 @@ namespace Marr.Data.QGen
/// </summary> /// </summary>
/// <param name="expression"></param> /// <param name="expression"></param>
/// <returns></returns> /// <returns></returns>
protected override System.Linq.Expressions.Expression Visit(System.Linq.Expressions.Expression expression) protected override Expression Visit(Expression expression)
{ {
return base.Visit(expression); return base.Visit(expression);
} }
@ -509,9 +510,9 @@ namespace Marr.Data.QGen
/// </summary> /// </summary>
/// <param name="lambdaExpression"></param> /// <param name="lambdaExpression"></param>
/// <returns></returns> /// <returns></returns>
protected override System.Linq.Expressions.Expression VisitLamda(System.Linq.Expressions.LambdaExpression lambdaExpression) protected override Expression VisitLamda(LambdaExpression lambdaExpression)
{ {
_sortBuilder = this.Where(lambdaExpression as Expression<Func<T, bool>>); _sortBuilder = Where(lambdaExpression as Expression<Func<T, bool>>);
return base.VisitLamda(lambdaExpression); return base.VisitLamda(lambdaExpression);
} }
@ -520,16 +521,16 @@ namespace Marr.Data.QGen
/// </summary> /// </summary>
/// <param name="expression"></param> /// <param name="expression"></param>
/// <returns></returns> /// <returns></returns>
protected override System.Linq.Expressions.Expression VisitMethodCall(MethodCallExpression expression) protected override Expression VisitMethodCall(MethodCallExpression expression)
{ {
if (expression.Method.Name == "OrderBy" || expression.Method.Name == "ThenBy") if (expression.Method.Name == "OrderBy" || expression.Method.Name == "ThenBy")
{ {
var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as System.Linq.Expressions.LambdaExpression).Body as System.Linq.Expressions.MemberExpression; var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as LambdaExpression).Body as MemberExpression;
_sortBuilder.Order(memberExp.Expression.Type, memberExp.Member.Name); _sortBuilder.Order(memberExp.Expression.Type, memberExp.Member.Name);
} }
if (expression.Method.Name == "OrderByDescending" || expression.Method.Name == "ThenByDescending") if (expression.Method.Name == "OrderByDescending" || expression.Method.Name == "ThenByDescending")
{ {
var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as System.Linq.Expressions.LambdaExpression).Body as System.Linq.Expressions.MemberExpression; var memberExp = ((expression.Arguments[1] as UnaryExpression).Operand as LambdaExpression).Body as MemberExpression;
_sortBuilder.OrderByDescending(memberExp.Expression.Type, memberExp.Member.Name); _sortBuilder.OrderByDescending(memberExp.Expression.Type, memberExp.Member.Name);
} }
@ -540,14 +541,14 @@ namespace Marr.Data.QGen
{ {
_isJoin = true; _isJoin = true;
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member; MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
return this.Join(joinType, rightMember, filterExpression); return Join(joinType, rightMember, filterExpression);
} }
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, TRight>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression) public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, TRight>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression)
{ {
_isJoin = true; _isJoin = true;
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member; MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
return this.Join(joinType, rightMember, filterExpression); return Join(joinType, rightMember, filterExpression);
} }
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression) public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression)
@ -598,7 +599,7 @@ namespace Marr.Data.QGen
IEnumerator<T> IEnumerable<T>.GetEnumerator() IEnumerator<T> IEnumerable<T>.GetEnumerator()
{ {
var list = this.ToList(); var list = ToList();
return list.GetEnumerator(); return list.GetEnumerator();
} }
@ -608,7 +609,7 @@ namespace Marr.Data.QGen
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
var list = this.ToList(); var list = ToList();
return list.GetEnumerator(); return list.GetEnumerator();
} }

@ -1,4 +1,5 @@
using System; using System;
using Marr.Data.Mapping;
using Marr.Data.QGen.Dialects; using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
@ -16,19 +17,19 @@ namespace Marr.Data.QGen
private const string DB_FireBirdClient = "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory"; private const string DB_FireBirdClient = "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory";
private const string DB_SQLiteClient = "System.Data.SQLite.SQLiteFactory"; private const string DB_SQLiteClient = "System.Data.SQLite.SQLiteFactory";
public static IQuery CreateUpdateQuery(Mapping.ColumnMapCollection columns, IDataMapper dataMapper, string target, string whereClause) public static IQuery CreateUpdateQuery(ColumnMapCollection columns, IDataMapper dataMapper, string target, string whereClause)
{ {
Dialect dialect = CreateDialect(dataMapper); Dialect dialect = CreateDialect(dataMapper);
return new UpdateQuery(dialect, columns, dataMapper.Command, target, whereClause); return new UpdateQuery(dialect, columns, dataMapper.Command, target, whereClause);
} }
public static IQuery CreateInsertQuery(Mapping.ColumnMapCollection columns, IDataMapper dataMapper, string target) public static IQuery CreateInsertQuery(ColumnMapCollection columns, IDataMapper dataMapper, string target)
{ {
Dialect dialect = CreateDialect(dataMapper); Dialect dialect = CreateDialect(dataMapper);
return new InsertQuery(dialect, columns, dataMapper.Command, target); return new InsertQuery(dialect, columns, dataMapper.Command, target);
} }
public static IQuery CreateDeleteQuery(Dialects.Dialect dialect, Table targetTable, string whereClause) public static IQuery CreateDeleteQuery(Dialect dialect, Table targetTable, string whereClause)
{ {
return new DeleteQuery(dialect, targetTable, whereClause); return new DeleteQuery(dialect, targetTable, whereClause);
} }
@ -81,7 +82,7 @@ namespace Marr.Data.QGen
} }
} }
public static Dialects.Dialect CreateDialect(IDataMapper dataMapper) public static Dialect CreateDialect(IDataMapper dataMapper)
{ {
string providerString = dataMapper.ProviderFactory.ToString(); string providerString = dataMapper.ProviderFactory.ToString();
switch (providerString) switch (providerString)

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Linq.Expressions; using System.Linq.Expressions;
@ -243,7 +244,7 @@ namespace Marr.Data.QGen
public virtual IEnumerator<T> GetEnumerator() public virtual IEnumerator<T> GetEnumerator()
{ {
var list = this.ToList(); var list = ToList();
return list.GetEnumerator(); return list.GetEnumerator();
} }
@ -251,7 +252,7 @@ namespace Marr.Data.QGen
#region IEnumerable Members #region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

@ -41,7 +41,7 @@ namespace Marr.Data.QGen
/// </summary> /// </summary>
public Table FindTable(Type declaringType) public Table FindTable(Type declaringType)
{ {
return this.EnumerateViewsAndTables().Where(t => t.EntityType == declaringType).FirstOrDefault(); return EnumerateViewsAndTables().Where(t => t.EntityType == declaringType).FirstOrDefault();
} }
public Table this[int index] public Table this[int index]

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Marr.Data.Mapping; using Marr.Data.Mapping;
using System.Linq.Expressions; using System.Linq.Expressions;
using Marr.Data.QGen.Dialects;
namespace Marr.Data.QGen namespace Marr.Data.QGen
{ {
@ -16,7 +17,7 @@ namespace Marr.Data.QGen
private bool _generateQuery = true; private bool _generateQuery = true;
private TableCollection _tables; private TableCollection _tables;
private Expression<Func<T, bool>> _filterExpression; private Expression<Func<T, bool>> _filterExpression;
private Dialects.Dialect _dialect; private Dialect _dialect;
private ColumnMapCollection _columnsToUpdate; private ColumnMapCollection _columnsToUpdate;
public UpdateQueryBuilder() public UpdateQueryBuilder()

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Marr.Data.Mapping; using Marr.Data.Mapping;
@ -11,7 +12,7 @@ namespace Marr.Data.QGen
{ {
private string _viewName; private string _viewName;
private Table[] _tables; private Table[] _tables;
private Mapping.ColumnMapCollection _columns; private ColumnMapCollection _columns;
public View(string viewName, Table[] tables) public View(string viewName, Table[] tables)
: base(tables[0].EntityType, JoinType.None) : base(tables[0].EntityType, JoinType.None)
@ -58,7 +59,7 @@ namespace Marr.Data.QGen
/// <summary> /// <summary>
/// Gets all the columns from all the tables included in the view. /// Gets all the columns from all the tables included in the view.
/// </summary> /// </summary>
public override Mapping.ColumnMapCollection Columns public override ColumnMapCollection Columns
{ {
get get
{ {
@ -81,9 +82,9 @@ namespace Marr.Data.QGen
} }
} }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return this.GetEnumerator(); return GetEnumerator();
} }
} }
} }

@ -78,7 +78,7 @@ namespace Marr.Data.QGen
protected override Expression VisitMethodCall(MethodCallExpression expression) protected override Expression VisitMethodCall(MethodCallExpression expression)
{ {
string method = (expression as System.Linq.Expressions.MethodCallExpression).Method.Name; string method = (expression as MethodCallExpression).Method.Name;
switch (method) switch (method)
{ {
case "Contains": case "Contains":
@ -270,7 +270,7 @@ namespace Marr.Data.QGen
internal void Append(WhereBuilder<T> where, WhereAppendType appendType) internal void Append(WhereBuilder<T> where, WhereAppendType appendType)
{ {
_constantWhereClause = string.Format("{0} {1} {2}", _constantWhereClause = string.Format("{0} {1} {2}",
this.ToString(), ToString(),
appendType.ToString(), appendType.ToString(),
where.ToString().Replace("WHERE ", string.Empty)); where.ToString().Replace("WHERE ", string.Empty));
} }

@ -1,4 +1,5 @@
using System; using System;
using System.Runtime.Serialization;
namespace Marr.Data namespace Marr.Data
{ {
@ -118,8 +119,8 @@ namespace Marr.Data
public NestedSharedContextRollBackException(string message) : base(message) { } public NestedSharedContextRollBackException(string message) : base(message) { }
public NestedSharedContextRollBackException(string message, Exception inner) : base(message, inner) { } public NestedSharedContextRollBackException(string message, Exception inner) : base(message, inner) { }
protected NestedSharedContextRollBackException( protected NestedSharedContextRollBackException(
System.Runtime.Serialization.SerializationInfo info, SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) StreamingContext context)
: base(info, context) { } : base(info, context) { }
} }
} }

@ -21,6 +21,7 @@ using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.RootFolders; using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Update; using NzbDrone.Core.Update;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using System.Linq; using System.Linq;
@ -31,7 +32,7 @@ namespace NzbDrone.Api.Test.MappingTests
public class ResourceMappingFixture : TestBase public class ResourceMappingFixture : TestBase
{ {
[TestCase(typeof(Core.Tv.Series), typeof(SeriesResource))] [TestCase(typeof(Core.Tv.Series), typeof(SeriesResource))]
[TestCase(typeof(Core.Tv.Episode), typeof(EpisodeResource))] [TestCase(typeof(Episode), typeof(EpisodeResource))]
[TestCase(typeof(RootFolder), typeof(RootFolderResource))] [TestCase(typeof(RootFolder), typeof(RootFolderResource))]
[TestCase(typeof(NamingConfig), typeof(NamingConfigResource))] [TestCase(typeof(NamingConfig), typeof(NamingConfigResource))]
[TestCase(typeof(Indexer), typeof(IndexerResource))] [TestCase(typeof(Indexer), typeof(IndexerResource))]

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Series namespace NzbDrone.Api.Series
@ -22,7 +23,7 @@ namespace NzbDrone.Api.Series
public DateTime? NextAiring { get; set; } public DateTime? NextAiring { get; set; }
public String Network { get; set; } public String Network { get; set; }
public String AirTime { get; set; } public String AirTime { get; set; }
public List<Core.MediaCover.MediaCover> Images { get; set; } public List<MediaCover> Images { get; set; }
public String RemotePoster { get; set; } public String RemotePoster { get; set; }

@ -17,7 +17,7 @@ namespace NzbDrone.Api
/// <returns>INancyEngine implementation</returns> /// <returns>INancyEngine implementation</returns>
protected override sealed INancyEngine GetEngineInternal() protected override sealed INancyEngine GetEngineInternal()
{ {
return this.ApplicationContainer.Resolve<INancyEngine>(); return ApplicationContainer.Resolve<INancyEngine>();
} }
/// <summary> /// <summary>
@ -26,7 +26,7 @@ namespace NzbDrone.Api
/// <returns>IModuleKeyGenerator instance</returns> /// <returns>IModuleKeyGenerator instance</returns>
protected override sealed IModuleKeyGenerator GetModuleKeyGenerator() protected override sealed IModuleKeyGenerator GetModuleKeyGenerator()
{ {
return this.ApplicationContainer.Resolve<IModuleKeyGenerator>(); return ApplicationContainer.Resolve<IModuleKeyGenerator>();
} }
/// <summary> /// <summary>
@ -114,7 +114,7 @@ namespace NzbDrone.Api
/// <returns>Request container instance</returns> /// <returns>Request container instance</returns>
protected override sealed TinyIoCContainer CreateRequestContainer() protected override sealed TinyIoCContainer CreateRequestContainer()
{ {
return this.ApplicationContainer.GetChildContainer(); return ApplicationContainer.GetChildContainer();
} }
/// <summary> /// <summary>
@ -123,7 +123,7 @@ namespace NzbDrone.Api
/// <returns>IDagnostics implementation</returns> /// <returns>IDagnostics implementation</returns>
protected override IDiagnostics GetDiagnostics() protected override IDiagnostics GetDiagnostics()
{ {
return this.ApplicationContainer.Resolve<IDiagnostics>(); return ApplicationContainer.Resolve<IDiagnostics>();
} }
/// <summary> /// <summary>
@ -132,7 +132,7 @@ namespace NzbDrone.Api
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationStartup"/> instances. </returns> /// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationStartup"/> instances. </returns>
protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks() protected override IEnumerable<IApplicationStartup> GetApplicationStartupTasks()
{ {
return this.ApplicationContainer.ResolveAll<IApplicationStartup>(false); return ApplicationContainer.ResolveAll<IApplicationStartup>(false);
} }
/// <summary> /// <summary>
@ -141,7 +141,7 @@ namespace NzbDrone.Api
/// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationRegistrations"/> instances.</returns> /// <returns>An <see cref="IEnumerable{T}"/> instance containing <see cref="IApplicationRegistrations"/> instances.</returns>
protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks() protected override IEnumerable<IApplicationRegistrations> GetApplicationRegistrationTasks()
{ {
return this.ApplicationContainer.ResolveAll<IApplicationRegistrations>(false); return ApplicationContainer.ResolveAll<IApplicationRegistrations>(false);
} }
/// <summary> /// <summary>

@ -1,4 +1,5 @@
using System; using System;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -53,7 +54,7 @@ namespace NzbDrone.Common
var byteSize = (length / 4) * 3; var byteSize = (length / 4) * 3;
var linkBytes = new byte[byteSize]; var linkBytes = new byte[byteSize];
var rngCrypto = new System.Security.Cryptography.RNGCryptoServiceProvider(); var rngCrypto = new RNGCryptoServiceProvider();
rngCrypto.GetBytes(linkBytes); rngCrypto.GetBytes(linkBytes);
var base64String = Convert.ToBase64String(linkBytes); var base64String = Convert.ToBase64String(linkBytes);

@ -42,7 +42,7 @@ namespace NzbDrone.Common.Instrumentation
} }
protected override void Write(NLog.LogEventInfo logEvent) protected override void Write(LogEventInfo logEvent)
{ {
var dictionary = new Dictionary<string, object>(); var dictionary = new Dictionary<string, object>();

@ -1,3 +1,4 @@
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace NzbDrone.Common namespace NzbDrone.Common
@ -38,8 +39,8 @@ namespace NzbDrone.Common
public static string RemoveAccent(this string txt) public static string RemoveAccent(this string txt)
{ {
var bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt); var bytes = Encoding.GetEncoding("Cyrillic").GetBytes(txt);
return System.Text.Encoding.ASCII.GetString(bytes); return Encoding.ASCII.GetString(bytes);
} }
} }
} }

@ -31,7 +31,7 @@ namespace NzbDrone.Core.Configuration
public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger) public ConfigFileProvider(IAppFolderInfo appFolderInfo, ICacheManger cacheManger)
{ {
_appFolderInfo = appFolderInfo; _appFolderInfo = appFolderInfo;
_cache = cacheManger.GetCache<string>(this.GetType()); _cache = cacheManger.GetCache<string>(GetType());
_configFile = _appFolderInfo.GetConfigPath(); _configFile = _appFolderInfo.GetConfigPath();
} }

@ -74,18 +74,18 @@ namespace NzbDrone.Core.Indexers
public void CheckForError() public void CheckForError()
{ {
if (this.MoveToContent() == XmlNodeType.Element) if (MoveToContent() == XmlNodeType.Element)
{ {
if (this.Name != "error") if (Name != "error")
return; return;
var message = "Error: "; var message = "Error: ";
if (this.HasAttributes) if (HasAttributes)
{ {
while (this.MoveToNextAttribute()) while (MoveToNextAttribute())
{ {
message += String.Format(" [{0}:{1}]", this.Name, this.Value); message += String.Format(" [{0}:{1}]", Name, Value);
} }
} }

@ -6,6 +6,7 @@ using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using NzbDrone.Update.UpdateEngine; using NzbDrone.Update.UpdateEngine;
using IServiceProvider = NzbDrone.Common.IServiceProvider;
namespace NzbDrone.Update.Test namespace NzbDrone.Update.Test
{ {
@ -19,7 +20,7 @@ namespace NzbDrone.Update.Test
Subject.Start(AppType.Service, targetFolder); Subject.Start(AppType.Service, targetFolder);
Mocker.GetMock<Common.IServiceProvider>().Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once()); Mocker.GetMock<IServiceProvider>().Verify(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
} }
@ -28,7 +29,7 @@ namespace NzbDrone.Update.Test
{ {
const string targetFolder = "c:\\NzbDrone\\"; const string targetFolder = "c:\\NzbDrone\\";
Mocker.GetMock<Common.IServiceProvider>().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException()); Mocker.GetMock<IServiceProvider>().Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME)).Throws(new InvalidOperationException());
Subject.Start(AppType.Service, targetFolder); Subject.Start(AppType.Service, targetFolder);

Loading…
Cancel
Save