本文整理汇总了C#中Csla.Data.SafeDataReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# SafeDataReader.Read方法的具体用法?C# SafeDataReader.Read怎么用?C# SafeDataReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Csla.Data.SafeDataReader
的用法示例。
在下文中一共展示了SafeDataReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DataPortal_Fetch
private void DataPortal_Fetch(CategoryCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
string commandText = String.Format("SELECT [CategoryId], [Name], [Descn] FROM [dbo].[Category] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if (reader.Read())
Map(reader);
else
throw new Exception(String.Format("The record was not found in 'dbo.Category' using the following criteria: {0}.", criteria));
}
}
}
OnFetched();
}
示例2: DataPortal_Fetch
private void DataPortal_Fetch(OrderCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [OrderId], [UserId], [OrderDate], [ShipAddr1], [ShipAddr2], [ShipCity], [ShipState], [ShipZip], [ShipCountry], [BillAddr1], [BillAddr2], [BillCity], [BillState], [BillZip], [BillCountry], [Courier], [TotalPrice], [BillToFirstName], [BillToLastName], [ShipToFirstName], [ShipToLastName], [AuthorizationNumber], [Locale] FROM [dbo].[Orders] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Tests.ParameterizedSQL.Order.GetOrder(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例3: Fetch
/// <summary>
/// Fetch ProfileList.
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
public ProfileList Fetch(ProfileCriteria criteria)
{
ProfileList item = (ProfileList)Activator.CreateInstance(typeof(ProfileList), true);
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return item;
// Fetch Child objects.
string commandText = String.Format("SELECT [UniqueID], [Username], [ApplicationName], [IsAnonymous], [LastActivityDate], [LastUpdatedDate] FROM [dbo].[Profiles] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if (reader.Read())
{
do
{
item.Add(new ProfileFactory().Map(reader));
} while(reader.Read());
}
}
}
}
MarkOld(item);
OnFetched();
return item;
}
示例4: Child_Fetch
private void Child_Fetch(OrderStatusCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [OrderId], [LineNum], [Timestamp], [Status] FROM [dbo].[OrderStatus] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Business.OrderStatus.GetOrderStatus(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例5: DataPortal_Fetch
private void DataPortal_Fetch(OrderCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand("[dbo].[CSLA_Order_Select]", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
command.Parameters.AddWithValue("@p_ShipAddr2HasValue", criteria.ShipAddr2HasValue);
command.Parameters.AddWithValue("@p_BillAddr2HasValue", criteria.BillAddr2HasValue);
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Tests.StoredProcedures.Order.GetOrder(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例6: Child_Fetch
private void Child_Fetch(AccountCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [AccountId], [UniqueID], [Email], [FirstName], [LastName], [Address1], [Address2], [City], [State], [Zip], [Country], [Phone] FROM [dbo].[Account] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Business.Account.GetAccount(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例7: Fetch
/// <summary>
/// Fetch CartList.
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
public CartList Fetch(CartCriteria criteria)
{
CartList item = (CartList)Activator.CreateInstance(typeof(CartList), true);
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return item;
// Fetch Child objects.
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand("[dbo].[CSLA_Cart_Select]", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
item.Add(new CartFactory().Map(reader));
} while(reader.Read());
}
}
}
}
MarkOld(item);
MarkAsChild(item);
OnFetched();
return item;
}
示例8: Fetch
/// <summary>
/// Fetch AccountList.
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
public AccountList Fetch(AccountCriteria criteria)
{
AccountList item = (AccountList)Activator.CreateInstance(typeof(AccountList), true);
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return item;
// Fetch Child objects.
string commandText = String.Format("SELECT [AccountId], [UniqueID], [Email], [FirstName], [LastName], [Address1], [Address2], [City], [State], [Zip], [Country], [Phone] FROM [dbo].[Account] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if (reader.Read())
{
do
{
item.Add(new AccountFactory().Map(reader));
} while(reader.Read());
}
}
}
}
MarkOld(item);
MarkAsChild(item);
OnFetched();
return item;
}
示例9: Fetch
/// <summary>
/// Fetch CartList.
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
public CartList Fetch(CartCriteria criteria)
{
CartList item = (CartList)Activator.CreateInstance(typeof(CartList), true);
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return item;
// Fetch Child objects.
string commandText = String.Format("SELECT [CartId], [UniqueID], [ItemId], [Name], [Type], [Price], [CategoryId], [ProductId], [IsShoppingCart], [Quantity] FROM [dbo].[Cart] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if (reader.Read())
{
do
{
item.Add(new CartFactory().Map(reader));
} while(reader.Read());
}
}
}
}
MarkOld(item);
MarkAsChild(item);
OnFetched();
return item;
}
示例10: Child_Fetch
private void Child_Fetch(SupplierCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [SuppId], [Name], [Status], [Addr1], [Addr2], [City], [State], [Zip], [Phone] FROM [dbo].[Supplier] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Tests.ParameterizedSQL.Supplier.GetSupplier(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例11: DataPortal_Fetch
private void DataPortal_Fetch(LineItemCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Tests.ParameterizedSQL.LineItem.GetLineItem(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例12: DataPortal_Fetch
private void DataPortal_Fetch(CategoryCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [CategoryId], [Name], [Descn] FROM [dbo].[Category] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Business.Category.GetCategory(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例13: Fetch
/// <summary>
/// Fetch OrderList.
/// </summary>
/// <param name="criteria">The criteria.</param>
/// <returns></returns>
public OrderList Fetch(OrderCriteria criteria)
{
OrderList item = (OrderList)Activator.CreateInstance(typeof(OrderList), true);
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return item;
// Fetch Child objects.
string commandText = String.Format("SELECT [OrderId], [UserId], [OrderDate], [ShipAddr1], [ShipAddr2], [ShipCity], [ShipState], [ShipZip], [ShipCountry], [BillAddr1], [BillAddr2], [BillCity], [BillState], [BillZip], [BillCountry], [Courier], [TotalPrice], [BillToFirstName], [BillToLastName], [ShipToFirstName], [ShipToLastName], [AuthorizationNumber], [Locale] FROM [dbo].[Orders] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if (reader.Read())
{
do
{
item.Add(new OrderFactory().Map(reader));
} while(reader.Read());
}
}
}
}
MarkOld(item);
MarkAsChild(item);
OnFetched();
return item;
}
示例14: Child_Fetch
private void Child_Fetch(CategoryCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand("[dbo].[CSLA_Category_Select]", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
command.Parameters.AddWithValue("@p_DescnHasValue", criteria.DescriptionHasValue);
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Tests.Collections.EditableChild.Category.GetCategory(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}
示例15: Child_Fetch
private void Child_Fetch(ItemCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
RaiseListChangedEvents = false;
// Fetch Child objects.
string commandText = String.Format("SELECT [ItemId], [ProductId], [ListPrice], [UnitCost], [Supplier], [Status], [Name], [Image] FROM [dbo].[Item] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(commandText, connection))
{
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
using(var reader = new SafeDataReader(command.ExecuteReader()))
{
if(reader.Read())
{
do
{
this.Add(PetShop.Business.Item.GetItem(reader));
} while(reader.Read());
}
}
}
}
RaiseListChangedEvents = true;
OnFetched();
}