本文整理汇总了C#中Csla.Data.SafeDataReader类的典型用法代码示例。如果您正苦于以下问题:C# SafeDataReader类的具体用法?C# SafeDataReader怎么用?C# SafeDataReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeDataReader类属于Csla.Data命名空间,在下文中一共展示了SafeDataReader类的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: 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;
}
示例3: 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();
}
示例4: GetPatientChartFilterList
public static ArrayList GetPatientChartFilterList()
{
ArrayList _filterList = new ArrayList();
using (SqlConnection cn = new SqlConnection(Database.WaldenConnect))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandText = "select Name, Description,FilterID"
+ " from PatientChartFilter"
+ " where AccountID =" + Common.AccountID
+ " and FilterId > 0"
+ " order by Description";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())
{
_filterList.Add(dr.GetString(0) + "~"
+ dr.GetString(1) + "~"
+ dr.GetInt32(2));
}
return _filterList;
}
}
}
}
示例5: DataPortal_Fetch
private void DataPortal_Fetch(OrderCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
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())
Map(reader);
else
throw new Exception(String.Format("The record was not found in 'dbo.Orders' using the following criteria: {0}.", criteria));
}
}
}
OnFetched();
}
示例6: 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();
}
示例7: 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();
}
示例8: GetDatabaseVersion
public string GetDatabaseVersion()
{
var mySQLString = "Select mdbVersion From tblCaptions";
if (GetConnection(out _myAccessConn)) return null;
try
{
using (var myAccessCommand = new OleDbCommand(mySQLString, _myAccessConn))
{
_myAccessConn.Open();
using (var dr = new SafeDataReader(myAccessCommand.ExecuteReader()))
using (dr)
while (dr.Read())
{
_mdbVersion = dr.GetString(dr.GetOrdinal("mdbVersion"));
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
return null;
}
finally
{
_myAccessConn.Close();
}
return _mdbVersion;
}
示例9: Child_Fetch
/// <summary>
/// Retrieves data from the data base into a CSLA editable child business object of type <see cref="Account"/>
/// using the criteria provided.
/// </summary>
/// <param name="criteria">Object of type <see cref="AccountCriteria"/></param>
/// <returns></returns>
private void Child_Fetch(AccountCriteria criteria)
{
bool cancel = false;
OnChildFetching(criteria, ref cancel);
if (cancel) return;
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())
Map(reader);
else
throw new Exception(String.Format("The record was not found in 'dbo.Account' using the following criteria: {0}.", criteria));
}
}
}
OnChildFetched();
}
示例10: GetTemplatesList
public static ArrayList GetTemplatesList(string _templateID)
{
ArrayList aTemplates = new ArrayList();
using (SqlConnection cn = new SqlConnection(Database.WaldenConnect))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandText = "SELECT TemplateTextID,AccountID,"
+ " TemplateID,Text "
+ " FROM TemplateForChoice"
+ " where AccountID = " + Common.AccountID
+ " and TemplateID = " + _templateID
+ " order by Text";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())
{
aTemplates.Add(dr["Text"] + "~"
+ dr["TemplateTextID"]);
// + dr.GetDateTime(1).ToShortDateString() + "~"
// + dr.GetString(2) + "~"
// + dr.GetString(3) + "~"
// + dr.GetInt32(4).ToString());
}
return aTemplates;
}
}
}
}
示例11: GetTemplates
public static ArrayList GetTemplates(string _templateType)
{
ArrayList aTemplates = new ArrayList();
using (SqlConnection cn = new SqlConnection(Database.WaldenConnect))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandText = "select B.Name ,B.TemplateID from TemplateType A,Templates B"
+ " where A.Name = '" + _templateType + "'"
+ " and A.AccountID = " + Common.AccountID
+ " and B.AccountID = " + Common.AccountID
+ " and A.TemplateTypeID = B.TemplateTypeID"
+ " order by B.Name";
Common.Log(cm.CommandText);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())
{
aTemplates.Add(dr.GetString(0) + "~"
+ dr.GetInt32(1).ToString());
// + dr.GetDateTime(1).ToShortDateString() + "~"
// + dr.GetString(2) + "~"
// + dr.GetString(3) + "~"
// + dr.GetInt32(4).ToString());
}
return aTemplates;
}
}
}
}
示例12: GetStringCollectionOfPatientChart
public static StringCollection GetStringCollectionOfPatientChart(string _id)
{
StringCollection items = new StringCollection();
using (SqlConnection cn = new SqlConnection(Database.WaldenConnect))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandText = "select ScanPath"
+ " from ScanPatientDocuments"
+ " where PatientID = " + _id
+ " and AccountID =" + Common.AccountID
+ " order by TabId,DateOfService";
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())
{
items.Add(Common.StoreComputer
+ Common.StoreShare + dr.GetString(0));
}
return items;
}
}
}
}
示例13: DataPortal_Fetch
private void DataPortal_Fetch(ItemCriteria criteria)
{
bool cancel = false;
OnFetching(criteria, ref cancel);
if (cancel) return;
using (var connection = new SqlConnection(ADOHelper.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand("[dbo].[CSLA_Item_Select]", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
command.Parameters.AddWithValue("@p_ListPriceHasValue", criteria.ListPriceHasValue);
command.Parameters.AddWithValue("@p_UnitCostHasValue", criteria.UnitCostHasValue);
command.Parameters.AddWithValue("@p_SupplierHasValue", criteria.SupplierHasValue);
command.Parameters.AddWithValue("@p_StatusHasValue", criteria.StatusHasValue);
command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
command.Parameters.AddWithValue("@p_ImageHasValue", criteria.ImageHasValue);
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.Item' using the following criteria: {0}.", criteria));
}
}
}
OnFetched();
}
示例14: 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;
}
示例15: 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();
}