我有一个网页,如果在搜索框中键入的内容然后迭代通过该值的文件,我需要它,以便搜索/查找不区分大小写.区分大小写必须保留在文件中,但为了进行比较,它忽略了大小写.所以目前我正在使用下划线命令:
arr=_.where(arr,filter);
Run Code Online (Sandbox Code Playgroud)
但是2个阵列arr和filter- 我需要比较/使用它们而不管情况如何,所以最终结果arr包含大小写混合但匹配值的结果arr.有人可以帮忙吗?
我有一个网格,我通过它的名称访问每个唯一的列,如下所示:
grid.Columns["SomeColumnA"]
Run Code Online (Sandbox Code Playgroud)
但是,我只能设置该列的属性,如果它不是null,如下所示:
if (grid.Columns["SomeColumnB"] != null) {
grid.Columns["SomeColumnB"].Width = 100;
}
Run Code Online (Sandbox Code Playgroud)
我有大约15/20个不同的列需要为各种事物设置,但它们都需要首先检查为null.这看起来有点乱,因为这是15/20的if陈述.我想知道这些if语句是否是最好的方法,或者我是否可以实现其他方法来简化它并整理代码.有什么想法/建议吗?
我有一个页面,它从文件中读取并根据在搜索框中输入的内容显示过滤结果.当我单击重置按钮时,它会清除我想要的搜索框,但我也希望清除过滤后的结果.如果我取消注释下面的呼叫,此时被评论 - 它可以工作,但搜索框不清除.
HTML:
<form>
<ul data-bind="foreach:properties">
<li><input data-bind="attr:{placeholder:id},event:{change:$root.onInputChange}, value:value, valueUpdate: 'afterkeydown'" /></li>
</ul>
<input type="reset" value="Reset"/>
<!--<input type="reset" value="Reset" data-bind="click:$root.onclick"/>-->
</form>
<p></p>
<table data-bind="foreach:itemsFiltered">
<tr data-bind="foreach:$parent.formatItem($data)">
<td data-bind="text:value"></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我需要搜索框和过滤结果来清除.
假设有一个 SQL 表:testTable,其中包含以下列:clientID、colA、colB、colC。
reference clientID colA colB colC
---------------------------------------------
001 1 test1 test2 test3
002 1 test1 ball2 test3
003 2 test1 ball2 test3
004 2 test1 ball2 test3
005 3 test1 test2 test3
006 4 test1 test2 test3
007 4 test1 test2 test3
009 5 test1 ball2 test3
---------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我想选择所有不同的行,其中 colB 类似于“test”并按 clientID 进行分组。所以我最终得到:
reference clientID colA colB colC
----------------------------------------------
001 1 test1 test2 test3
005 3 test1 test2 test3
006 4 test1 test2 test3
----------------------------------------------
Run Code Online (Sandbox Code Playgroud)
编辑:如果我使用 select unique …
我想在控制器之外的另一个类(称为 FileWatcher)中访问数据库/dbContext。这个 web 应用程序还使用 Hangfire 不断监听新创建的文件的目录,它需要解析文件并将信息添加到数据库中。
所以我的 startup.cs 看起来像:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<JobsContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddHangfire(config =>
config.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHangfireDashboard("/hangfire");
app.UseHangfireServer();
FileWatcher = new FileWatcher();
BackgroundJob.Enqueue(() => FileWatcher.Watch());
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
Run Code Online (Sandbox Code Playgroud)
我的 FileWatcher 类:
public class FileWatcher
{ …Run Code Online (Sandbox Code Playgroud) c# ×2
html5 ×2
javascript ×2
arrays ×1
asp.net-core ×1
database ×1
dbcontext ×1
ef-core-2.2 ×1
group-by ×1
if-statement ×1
jquery ×1
lowercase ×1
null ×1
reset ×1
sql ×1
sql-like ×1
sql-server ×1
where-clause ×1