本文整理汇总了C#中Where类的典型用法代码示例。如果您正苦于以下问题:C# Where类的具体用法?C# Where怎么用?C# Where使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Where类属于命名空间,在下文中一共展示了Where类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUser
/// <summary>
/// 获取数据。此数据会持续增长,所以不建议一次性缓存。建议单个Model实体缓存。
/// </summary>
public BaseResult GetUser(TestTableParam param)
{
var where = new Where<TestTable>();
#region 模糊搜索条件
if (!string.IsNullOrWhiteSpace(param.SearchName))
{
where.And(d => d.Name.Like(param.SearchName));
}
if (!string.IsNullOrWhiteSpace(param.SearchIDNumber))
{
where.And(d => d.IDNumber.Like(param.SearchIDNumber));
}
if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone))
{
where.And(d => d.MobilePhone.Like(param.SearchMobilePhone));
}
#endregion
#region 是否分页
var dateCount = 0;
if (param._PageIndex != null && param._PageSize != null)
{
//取总数,以计算共多少页。自行考虑将总数缓存。
dateCount = TestTableRepository.Count(where);//.SetCacheTimeOut(10)
}
#endregion
var list = TestTableRepository.Query(where, d => d.CreateTime, "desc", null, param._PageSize, param._PageIndex);
return new BaseResult(true, list, "", dateCount);
}
示例2: GetDisplayValues
/// <summary>
/// Define com as propriedades serão dispostas na grid
/// </summary>
/// <param name="where">Filtros a serem informados</param>
/// <returns></returns>
public override IDisplayValues GetDisplayValues(Where where = null)
{
IDisplayValues result = base.GetDisplayValues(where);
result.Columns.Clear();
result.Columns.Add(new Parameter("GUID", GenericDbType.String, "sis_log.guid"));
result.Columns.Add(new Parameter("IP", GenericDbType.String, "sis_log.ip"));
result.Columns.Add(new Parameter("Nome do computador", GenericDbType.String, "sis_log.nomemaquina"));
result.Columns.Add(new Parameter("Data do evento", GenericDbType.Date, "sis_log.datahoraevento"));
result.Columns.Add(new Parameter("Evento", GenericDbType.String, "sis_log.evento"));
result.Columns.Add(new Parameter("MD5", GenericDbType.String, "sis_logibpt.md5"));
result.Columns.Add(new Parameter("Caminho", GenericDbType.String, "sis_logibpt.caminho"));
result.DynamicPaging = (w) =>
{
result = DbContext.GetDisplayValues(this, w);
DataReader dataReader = result.DataReader;
result.Values = (from x in dataReader
select new object[]
{
x["p_GUID"],
x["p_ip"],
x["p_nomemaquina"],
x["p_datahoraevento"],
x["p_evento"],
x["p_md5"],
x["p_caminho"]
}).ToList();
return result;
};
return result;
}
示例3: GetUser
/// <summary>
/// 获取数据。
/// </summary>
public BaseResult GetUser(TestTableParam param)
{
var where = new Where<TestTable>();
#region 模糊搜索条件
if (!string.IsNullOrWhiteSpace(param.SearchName))
{
where.And(d => d.Name.Like(param.SearchName));
}
if (!string.IsNullOrWhiteSpace(param.SearchIDNumber))
{
where.And(d => d.IDNumber.Like(param.SearchIDNumber));
}
if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone))
{
where.And(d => d.MobilePhone.Like(param.SearchMobilePhone));
}
#endregion
var fs = DB.Context.From<TestTable>()
.Where(where)
.OrderByDescending(d => d.CreateTime);
#region 是否分页
var dateCount = 0;
if (param.pageIndex != null && param.pageSize != null)
{
//取总数,以计算共多少页。自行考虑将总数缓存。
dateCount = fs.Count();//.SetCacheTimeOut(10)
fs.Page(param.pageSize.Value, param.pageIndex.Value);
}
#endregion
var list = fs.ToList();
return new BaseResult(true, list, "", dateCount);
}
示例4: Select
public Select(Expression selectItem, From.From from, Where.Where where)
{
SelectList = new List<Expression>();
SelectList.Add(selectItem);
From = from;
Where = where;
}
示例5: GetDisplayValues
public override IDisplayValues GetDisplayValues(Where where = null)
{
IDisplayValues result = DbContext.GetDisplayValues(this, where);
result.Columns.Clear();
result.Columns = new List<Parameter> {
new Parameter {
ParameterName = "GUID"
},
new Parameter {
ParameterName = "Código",
SourceColumn = "EGUID",
},
new Parameter {
ParameterName = "Estado",
SourceColumn = "Nome",
},
new Parameter{
ParameterName = "UF",
SourceColumn = "UF"
}
};
result.Values = (from x in result.DataReader
select new[]{
x["p_GUID"],
x["p_EGUID"],
x["p_Nome"],
x["p_UF"]
}).ToList();
return result;
}
示例6: GetDisplayValues
public override IDisplayValues GetDisplayValues(Where where = null)
{
IDisplayValues result = base.GetDisplayValues(where);
result.Columns.Clear();
result.Columns.Add(new Parameter("GUID", GenericDbType.String, "fat_Lan.GUID"));
result.Columns.Add(new Parameter("Código", GenericDbType.String, "fat_LanMOVPV.EGUID"));
result.Columns.Add(new Parameter("Cliente", GenericDbType.String, "fat_LanMovDadoPessoa.NomeFantasia"));
result.Columns.Add(new Parameter("Valor", GenericDbType.String, "fat_LanMov.vlrtotalliquido"));
result.DynamicPaging = (w) =>
{
result = DbContext.GetDisplayValues(this, w);
DataReader dr = result.DataReader;
result.Values = (from x in dr
select new object[] {
x["p_GUID"],
x["p_EGUID"],
x["p_DPNomeFantasia"],
Unimake.Format.Currency(x["p_VlrTotalLiquido"])
}).ToList();
return result;
};
return result;
}
示例7: CreateNewEvent
private void CreateNewEvent()
{
//Set Event Entry
Google.GData.Calendar.EventEntry oEventEntry = new Google.GData.Calendar.EventEntry();
oEventEntry.Title.Text = "Test Calendar Entry From .Net for testing";
oEventEntry.Content.Content = "Hurrah!!! I posted my second Google calendar event through .Net";
//Set Event Location
Where oEventLocation = new Where();
oEventLocation.ValueString = "Mumbai";
oEventEntry.Locations.Add(oEventLocation);
//Set Event Time
When oEventTime = new When(new DateTime(2012, 8, 05, 9, 0, 0), new DateTime(2012, 8, 05, 9, 0, 0).AddHours(1));
oEventEntry.Times.Add(oEventTime);
//Set Additional Properties
ExtendedProperty oExtendedProperty = new ExtendedProperty();
oExtendedProperty.Name = "SynchronizationID";
oExtendedProperty.Value = Guid.NewGuid().ToString();
oEventEntry.ExtensionElements.Add(oExtendedProperty);
CalendarService oCalendarService = GAuthenticate();
Uri oCalendarUri = new Uri("http://www.google.com/calendar/feeds/pankaj.sevlani[email protected]/private/full");
//Prevents This Error
//{"The remote server returned an error: (417) Expectation failed."}
System.Net.ServicePointManager.Expect100Continue = false;
//Save Event
oCalendarService.Insert(oCalendarUri, oEventEntry);
}
示例8: Execute
/// <summary>
/// Instancia uma nova MappingEngine pelo nó definido no XML. Se o nó não existir será retornado um erro
/// </summary>
///<param name="typeMapping">tipo que será mapeado pelo ETLMapping.xml</param>
///<param name="executing">Ação que deverá ser chamada ao executar algo</param>
///<param name="onEnd">Ação executada ao terminar a integração do registro</param>
///<param name="onStart">Ação executada ao iniciar a integração do registro</param>
///<param name="where">Filtro que será usado pelo select, se existir. Pode ser nulo</param>
public void Execute(Type typeMapping,
Action<ExecuteEventArgs> executing,
Action<ExecuteEventArgs> onStart,
Action<ExecuteEventArgs> onEnd,
Where where)
{
Execute(typeMapping, executing, onStart, onEnd, "", where);
}
示例9: ImportOrder
/// <summary>
/// Instancia este objeto e filtra pelo número do Pedido
/// </summary>
/// <param name="orderId"></param>
public ImportOrder(string orderId)
{
Where = new Where();
Where.Parameters.Add(new Parameter("@value", GenericDbType.String)
{
Value = orderId
});
Tag = "Pedido";
}
示例10: Target
/// <summary>
/// Create a new <see cref="Target"/>.
/// </summary>
/// <param name="expression">
/// The <see cref="EffectExpression"/> this is part of. This cannot be null.
/// </param>
/// <param name="targetType">
/// The actual target of the <see cref="EffectComponent"/>.
/// </param>
/// <param name="where">
/// Where the target is, or null if that is unspecified.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="expression"/> cannot be null.
/// </exception>
public Target(EffectExpression expression, TargetType targetType, Where where)
{
if (expression == null)
{
throw new ArgumentNullException("expression");
}
this.Expression = expression;
this.TargetType = targetType;
this.Where = where;
}
示例11: Or_Expression
public void Or_Expression()
{
var expr =
new Where<TestClass>().Like(x => x.A, "Alice").Or().SmallerThan(x => x.B, 2);
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE [AA] LIKE @A OR [B]<@B",
sql);
Assert.AreEqual(2, param.Count);
}
示例12: And_Expression_2
public void And_Expression_2()
{
var expr =
new Where<TestClass>().Group(g => g.Like(x => x.A, "Alice").And().SmallerThan(x => x.B, 2));
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE ([AA] LIKE @A AND [B]<@B)",
sql);
Assert.AreEqual(2, param.Count);
}
示例13: btnAdd_Click
/// <summary>
/// Handles the Click event of the btnAdd control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
protected void btnAdd_Click(object sender, EventArgs e)
{
try {
int attributeId = 0;
int attributeItemId = 0;
int.TryParse(lblAttributeId.Text, out attributeId);
int.TryParse(lblAttributeItemId.Text, out attributeItemId);
AttributeItem attributeItem;
if (attributeId > 0) {
Where where = new Where();
where.ColumnName = AttributeItem.Columns.AttributeId;
where.DbType = DbType.Int32;
where.ParameterValue = attributeId;
Query query = new Query(AttributeItem.Schema);
object strSortOrder = query.GetMax(AttributeItem.Columns.SortOrder, where);
int maxSortOrder = 0;
int.TryParse(strSortOrder.ToString(), out maxSortOrder);
if (attributeItemId > 0) {
attributeItem = new AttributeItem(attributeItemId);
}
else {
attributeItem = new AttributeItem();
attributeItem.SortOrder = maxSortOrder + 1;
}
attributeItem.AttributeId = attributeId;
attributeItem.Name = Server.HtmlEncode(txtAttributeItemName.Text.Trim());
decimal adjustment = 0;
decimal.TryParse(txtAdjustment.Text, out adjustment);
attributeItem.Adjustment = adjustment;
if (!string.IsNullOrEmpty(txtSkuSuffix.Text)) {
attributeItem.SkuSuffix = txtSkuSuffix.Text;
}
else {
attributeItem.SkuSuffix = CoreUtility.GenerateRandomString(3);
}
attributeItem.Save(WebUtility.GetUserName());
LoadAttributeItems();
ResetAttributeItem();
}
}
catch (Exception ex) {
Logger.Error(typeof(attributeedit).Name + ".btnAdd_Click", ex);
Master.MessageCenter.DisplayCriticalMessage(ex.Message);
}
}
示例14: Complex_Expression_1
public void Complex_Expression_1()
{
var expr =
new Where<TestClass>().IsEqual(x => x.A, "Bob")
.And(g => g.Like(x => x.B, "Alice").Or().SmallerThan(x => x.C, 2))
.And(g => g.GreaterThanOrEqualTo(x => x.C, 3).Or().IsEqual(x => x.D, "Chris"));
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE [AA][email protected] AND ([B] LIKE @B OR [CC]<@C) AND ([CC]>[email protected] OR [D][email protected])",
sql);
Assert.AreEqual(5, param.Count);
}
示例15: SintegraReg60M
/// <summary>
/// Instancia este objeto e carrega o mesmo com os dados de número de série e data informados
/// <param name="dataEmissao">Data de emissão do documentos</param>
/// <param name="numeroSerie">Número de série do ECF</param>
/// </summary>
public SintegraReg60M(DateTime dataEmissao, string numeroSerie)
: this()
{
Where w = new Where {
{ "DataEmissao = @p1", new Parameter{
ParameterName = "@p1",
Value = dataEmissao ,
GenericDbType = GenericDbType.Date}
},
{ "NumSerie = @p2", new Parameter{
ParameterName = "@p2",
Value = numeroSerie}
}
};
DbContext.Populate(this, w);
}