- Code.zip
- Code
- Global
- EncodeFirst.Core
- Attributes
- bin
- Debug
- DI.Global.dll
- DataAccess
- EncodeFirst.Core.csproj
- EncodeFirst.Core.csproj.user
- Helpers
- Managers
- obj
- Properties
- Types
- DataModel
- Filters
- Include.sln
- Include.suo
- TestService
- EncodeFirst.TestService.BusinessObjects
- EncodeFirst.TestService.DataAccess
- EncodeFirst.TestService.Global
- bin
- Debug
- ConfigService.Cache.dll
- ConfigService.CacheDataContract.dll
- DI.Global.dll
- DI.TestService.BusinessObjects.dll
- DI.TestService.Global.dll
- EncodeFirst.TestService.Core.csproj
- Managers
- obj
- Properties
- UnitTest
- App.config
- bin
- Debug
- ConfigService.Cache.dll
- ConfigService.CacheDataContract.dll
- ConfigService.IConfigActions.dll
- ConfigService.RuntimeHostData.dll
- ConfigService.ServiceConfiguration.DALFactory.dll
- ConfigService.ServiceConfiguration.DataContract.dll
- ConfigService.ServiceConfiguration.IDAL.dll
- ConfigService.ServiceConfigurationContract.dll
- ConfigService.ServiceConfigurationHelper.dll
- ConfigService.ServiceConfigurationUtility.dll
- ConfigService.ServiceNodeCommunication.DataContract.dll
- ConfigService.ServiceNodeCommunicationContract.dll
- DI.TestService.BusinessRules.dll
- DataAccess
- obj
- Debug
- TempPE
- Properties
- UnitTest.csproj
- Scripts.zip
- Scripts
|
using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Collections.Generic;
using EncodeFirst.Core;
using EncodeFirst.Core.Managers;
using EncodeFirst.Core.DataAccess;
using EncodeFirst.TestService.Core.Managers;
using EncodeFirst.TestService.BusinessObjects.Types;
using EncodeFirst.TestService.BusinessObjects.Contracts;
using EncodeFirst.TestService.BusinessObjects.Types.Filters;
using EncodeFirst.TestService.BusinessObjects.Types.DataModel;
namespace EncodeFirst.TestService.DataAccess
{
public class CustomerRepository : RepositoryBase, ICustomerRepository
{
/// <summary>
/// Initializes a new instance of the <see cref="RepositoryBase"/> class.
/// </summary>
/// <param name="connectionString">The connection string.</param>
/// <remarks></remarks>
public CustomerRepository() : base()
{
}
/// <summary>
/// Inits the repository.
/// </summary>
/// <remarks></remarks>
protected override void InitRepository()
{
_sqlConnection = new SqlConnection(SettingsManager.Instance.TestServiceDBConnectionString);
}
/// <summary>
/// Gets the customer.
/// </summary>
/// <param name="customerId">The customer id.</param>
/// <returns></returns>
/// <remarks></remarks>
public Customer GetCustomer(long id)
{
return GetEntity<Customer>("Customers_Get", new Customer() { Id = id });
}
/// <summary>
/// Gets the name of the customer by.
/// </summary>
/// <param name="name">The name.</param>
/// <returns></returns>
/// <remarks></remarks>
public Customer GetCustomerByName(string name)
{
return ExecuteQueryMethod<Customer>(delegate()
{ //Here: Do whatever is needed before call the Stored Procedure.
_parameters = new List<SqlParameter>();
_parameters.Add(new SqlParameter("@Name", name));
return SqlHelper.GetEntity<Customer>(_sqlConnection, "Customers_GetByName", _parameters);
});
}
/// <summary>
/// Gets the customers list.
/// </summary>
/// <returns></returns>
/// <remarks></remarks>
public Customer[] GetCustomersList()
{
return GetEntitiesList<Customer>("Customers_GetList");
}
/// <summary>
/// Gets the customers list by filter.
/// </summary>
/// <param name="filter">The filter.</param>
/// <returns></returns>
/// <remarks></remarks>
public Customer[] GetCustomersListByFilter(CustomerFilter filter, out int totalRows)
{
return GetEntitiesListByFilter<Customer>("Customers_GetByFilter", filter, out totalRows);
}
/// <summary>
/// Inserts the specified customer.
/// </summary>
/// <param name="customer">The customer.</param>
/// <returns></returns>
/// <remarks></remarks>
public bool Insert(Customer customer)
{
return InsertEntity("Customers_Insert", customer);
}
/// <summary>
/// Updates the specified customer.
/// </summary>
/// <param name="customer">The customer.</param>
/// <returns></returns>
/// <remarks></remarks>
public bool Update(Customer customer)
{
return UpdateEntity("Customers_Update", customer);
}
/// <summary>
/// Deletes the specified customer id.
/// </summary>
/// <param name="customerId">The customer id.</param>
/// <returns></returns>
/// <remarks></remarks>
public bool Delete(long id)
{
return DeleteEntity<Customer>("Customers_Delete", new Customer() { Id = id });
}
/// <summary>
/// Deletes the specified customer ids.
/// </summary>
/// <param name="ids">The ids.</param>
/// <returns></returns>
/// <remarks></remarks>
public bool Delete(long[] ids)
{
bool result = false;
if (ids != null && ids.Length > 0)
{
List<SqlDataRecord> idsList = new List<SqlDataRecord>();
SqlMetaData[] idsListDefinition = { new SqlMetaData("id", SqlDbType.BigInt) };
foreach (long id in ids)
{
SqlDataRecord value = new SqlDataRecord(idsListDefinition);
value.SetInt64(0, id);
idsList.Add(value);
}
result = DeleteEntitiesList("Customers_DeleteList", idsList);
}
return result;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.