本文整理汇总了C#中PetaPoco.DisplayField类的典型用法代码示例。如果您正苦于以下问题:C# DisplayField类的具体用法?C# DisplayField怎么用?C# DisplayField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DisplayField类属于PetaPoco命名空间,在下文中一共展示了DisplayField类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDisplayFields
/// <summary>
/// Displayfields provide a minimal name/value context for data binding the row collection of transactions.non_gl_stock_tax_details.
/// </summary>
/// <returns>Returns an enumerable name and value collection for the table transactions.non_gl_stock_tax_details</returns>
/// <exception cref="UnauthorizedException">Thown when the application user does not have sufficient privilege to perform this action.</exception>
public IEnumerable<DisplayField> GetDisplayFields()
{
List<DisplayField> displayFields = new List<DisplayField>();
if(string.IsNullOrWhiteSpace(this.Catalog))
{
return displayFields;
}
if (!this.SkipValidation)
{
if (!this.Validated)
{
this.Validate(AccessTypeEnum.Read, this.LoginId, false);
}
if (!this.HasAccess)
{
Log.Information("Access to get display field for entity \"NonGlStockTaxDetail\" was denied to the user with Login ID {LoginId}", this.LoginId);
throw new UnauthorizedException("Access is denied.");
}
}
const string sql = "SELECT non_gl_stock_tax_detail_id AS key, non_gl_stock_tax_detail_id as value FROM transactions.non_gl_stock_tax_details;";
using (NpgsqlCommand command = new NpgsqlCommand(sql))
{
using (DataTable table = DbOperation.GetDataTable(this.Catalog, command))
{
if (table?.Rows == null || table.Rows.Count == 0)
{
return displayFields;
}
foreach (DataRow row in table.Rows)
{
if (row != null)
{
DisplayField displayField = new DisplayField
{
Key = row["key"].ToString(),
Value = row["value"].ToString()
};
displayFields.Add(displayField);
}
}
}
}
return displayFields;
}
示例2: GetDisplayFields
/// <summary>
/// Displayfields provide a minimal name/value context for data binding the row collection of core.compound_unit_scrud_view.
/// </summary>
/// <returns>Returns an enumerable name and value collection for the view core.compound_unit_scrud_view</returns>
/// <exception cref="UnauthorizedException">Thown when the application user does not have sufficient privilege to perform this action.</exception>
public IEnumerable<DisplayField> GetDisplayFields()
{
List<DisplayField> displayFields = new List<DisplayField>();
if (string.IsNullOrWhiteSpace(this._Catalog))
{
return displayFields;
}
if (!this.SkipValidation)
{
if (!this.Validated)
{
this.Validate(AccessTypeEnum.Read, this._LoginId, this._Catalog, false);
}
if (!this.HasAccess)
{
Log.Information("Access to get display field for entity \"CompoundUnitScrudView\" was denied to the user with Login ID {LoginId}", this._LoginId);
throw new UnauthorizedException("Access is denied.");
}
}
const string sql = "SELECT compound_unit_id AS key, base_unit_name as value FROM core.compound_unit_scrud_view;";
using (NpgsqlCommand command = new NpgsqlCommand(sql))
{
using (DataTable table = DbOperation.GetDataTable(this._Catalog, command))
{
if (table?.Rows == null || table.Rows.Count == 0)
{
return displayFields;
}
foreach (DataRow row in table.Rows)
{
if (row != null)
{
DisplayField displayField = new DisplayField
{
Key = row["key"].ToString(),
Value = row["value"].ToString()
};
displayFields.Add(displayField);
}
}
}
}
return displayFields;
}
示例3: GetDisplayFields
/// <summary>
/// Displayfields provide a minimal name/value context for data binding the row collection of office.cash_repositories.
/// </summary>
/// <returns>Returns an enumerable name and value collection for the table office.cash_repositories</returns>
public IEnumerable<DisplayField> GetDisplayFields()
{
List<DisplayField> displayFields = new List<DisplayField>();
if(string.IsNullOrWhiteSpace(this.Catalog))
{
return displayFields;
}
try
{
if (!this.SkipValidation)
{
if (!this.Validated)
{
this.Validate(AccessTypeEnum.Read, this.LoginId, false);
}
if (!this.HasAccess)
{
throw new UnauthorizedException("Access is denied.");
}
}
const string sql = "SELECT cash_repository_id AS key, cash_repository_id as value FROM office.cash_repositories;";
using (NpgsqlCommand command = new NpgsqlCommand(sql))
{
using (DataTable table = DbOperation.GetDataTable(this.Catalog, command))
{
if (table?.Rows == null || table.Rows.Count == 0)
{
return displayFields;
}
foreach (DataRow row in table.Rows)
{
if (row != null)
{
DisplayField displayField = new DisplayField
{
Key = row["key"].ToString(),
Value = row["value"].ToString()
};
displayFields.Add(displayField);
}
}
}
}
return displayFields;
}
catch (UnauthorizedException ex)
{
Log.Error("{Exception} {@Exception}", ex.Message, ex);
throw new MixERPException(ex.Message, ex);
}
}