/// <summary> /// Deletes the matching entities from the database table /// </summary> /// <param name="where">The expression to filter entities. This translates to WHERE clause in SQL</param> public static void Delete(Expression <Func <T, bool> > where) { using (var manager = new DotEntityQueryManager()) { manager.DoDelete(where); } }
/// <summary> /// Updates the database table row that matches the primary key of the provided entity with the entity property values /// </summary> /// <param name="entity">The entity object for performing the update</param> public static void Update(T entity) { using (var manager = new DotEntityQueryManager()) { manager.DoUpdate(entity); } }
T IEntitySet <T> .SelectSingle() { using (var manager = new DotEntityQueryManager()) { return(manager.DoSelectSingle(_whereList, _orderBy)); } }
/// <summary> /// Inserts a new entity of specified type into database table /// </summary> /// <param name="entity">The entity to be inserted</param> public static void Insert(T entity) { using (var manager = new DotEntityQueryManager()) { manager.DoInsert(entity); } }
IEnumerable <T> IEntitySet <T> .Select(int page, int count) { using (var manager = new DotEntityQueryManager(_cache)) { return(manager.DoSelect(_whereList, _orderBy, page, count)); } }
int IEntitySet <T> .Count() { using (var manager = new DotEntityQueryManager()) { return(manager.DoCount <T>(_whereList)); } }
/// <summary> /// Executes the provided <paramref name="query"/> against the data provider and returns value of first row and first column of the result. /// </summary> /// <typeparam name="TType">The type of the return value</typeparam> /// <param name="query">The query to be executed against the provider. The query parameters references should be named with '@' prefix</param> /// <param name="parameters">(optional) A dynamic object containing the parameters used in the query</param> /// <returns>A value of type <typeparamref name="TType"/></returns> public static TType QueryScaler <TType>(string query, object parameters = null) { using (var manager = new DotEntityQueryManager()) { return(manager.DoScaler <TType>(query, parameters)); } }
/// <summary> /// Queries the database for the requested entities /// </summary> /// <returns>An enumeration of <typeparamref name="T"/></returns> public static IEnumerable <T> Select() { using (var manager = new DotEntityQueryManager()) { return(manager.DoSelect <T>()); } }
/// <summary> /// Updates the database table row that matches the provided <paramref name="where"/> expression /// </summary> /// <param name="entity">A dynamic object containing the fields to be updated with their new values</param> /// <param name="where">The filter expression to select appropriate database rows to update. This translates to WHERE clause in SQL</param> public static void Update(object entity, Expression <Func <T, bool> > where) { using (var manager = new DotEntityQueryManager()) { manager.DoUpdate(entity, where); } }
IEnumerable <T> IEntitySet <T> .SelectWithTotalMatches(out int totalMatches, int page, int count) { using (var manager = new DotEntityQueryManager()) { var selectWithCount = manager.DoSelectWithTotalMatches(_whereList, _orderBy, page, count); totalMatches = selectWithCount.Item1; return(selectWithCount.Item2); } }
/// <summary> /// Executes the provided <paramref name="query"/> against the data provider and returns the first result of the set /// </summary> /// <param name="query">The query to be executed against the provider. The query parameters references should be named with '@' prefix</param> /// <param name="parameters">(optional) A dynamic object containing the parameters used in the query</param> /// <param name="queryCache">(optional) The query cache to be used for the query</param> /// <param name="cacheParameters">(optional) The cache parameters that'll be replaced in the query</param> /// <returns>An enumeration of <typeparamref name="T"/></returns> public static T QuerySingle(string query, object parameters = null, QueryCache queryCache = null, object[] cacheParameters = null) { if (queryCache != null) { queryCache.ParameterValues = cacheParameters; } using (var manager = new DotEntityQueryManager(queryCache)) { return(manager.DoSingle <T>(query, parameters)); } }