好吧,例如,我按照这样的方式使用:星期一= 1,星期二= 2,星期三= 4,星期四= 8等...
我正在使用Entity Framework类的Business.
我正在使用一个类并传递一个像7(星期一,星期二,星期三)的值.
我想返回与那些日子相匹配的记录
public List<Business> GetBusinesses(long daysOfWeek)
{
using (var c = Context())
{
return c.Businesses.Where(???).ToList();
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.谢谢!
编辑
好的,我正在尝试以下方法:
var b = new List<Business>();
var b1 = new Business(){DaysOfWeek = 3};
b.Add(b1);
var b2 = new Business() { DaysOfWeek = 2 };
b.Add(b2);
var decomposedList = new[]{1};
var l = b.Where(o => decomposedList.Any(day => day == o.DaysOfWeek)).ToList();
Run Code Online (Sandbox Code Playgroud)
但是l返回0结果假设在decomposedList(1)我正在寻找星期一.我创建了包含星期一和星期二的b1.
我正在寻找一个简单的本机.NET错误日志记录解决方案.我对使用log4net,Elmah或任何其他日志库不感兴趣.以下是我计划使用的内容.我的问题是我的网站上的性能是至关重要的,这个流程是否会引入任何性能问题?
Global.asax中
protected void Application_Start(object sender, EventArgs e)
{
GlobalFilters.Filters.Add(new HandleExceptionsAttribute());
}
Run Code Online (Sandbox Code Playgroud)
处理异常属性:
public sealed class HandleExceptionsAttribute : HandleErrorAttribute
{
private void TraceError(Exception _this)
{
Trace.TraceError("{0} Exception {1}", DateTime.Now.ToString("M/d/yyyy h:mmtt"), _this);
}
public override void OnException(ExceptionContext filterContext)
{
var ex = filterContext.Exception;
TraceError(ex);
Task.Run(() =>
{
using (var msg = new MailMessage(ConfigurationManager.AppSettings["SendErrorsFrom"], ConfigurationManager.AppSettings["SendErrorsTo"]))
{
msg.Subject = ex.Message;
msg.Body = ex.StackTrace;
using (var smtp = new SmtpClient())
smtp.Send(msg);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
web.config中:
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="textWriterListener" type="System.Diagnostics.TextWriterTraceListener" …
Run Code Online (Sandbox Code Playgroud) 你好我的aspx页面使用MVC 3,我有以下代码:
<%Response.WriteFile("/Content/Bing.htm"); %>
Run Code Online (Sandbox Code Playgroud)
哪个是包含BING搜索框代码的包含文件.
在包含DIV的顶部,出现了一个奇怪的角色:
一世"
我意识到这可能是一个BOM Byte Order Marker,但对于我的生活,我无法弄清楚它为什么会出现以及如何摆脱它.其余的bing代码显示并正常工作.
基本上我希望能够在我的aspx页面中包含htm文件.
任何帮助,将不胜感激.谢谢.
我正在尝试使用以下代码使用Web服务将文件添加到Sharepoint Office365上的文档库中.
public void SaveFileToSharePoint(string fileName)
{
try
{
var copyService = new Copy { Url = "https://mydomain.com/_vti_bin/copy.asmx", Credentials = new NetworkCredential("username", "password", "domain") };
var destURL = "https://mydomain.com/Shared%20Documents/" + Path.GetFileName(fileName);
string[] destinationUrl = { destURL };
CopyResult[] cResultArray;
var fFiledInfo = new FieldInformation { DisplayName = "Description", Type = FieldType.Text, Value = Path.GetFileName(fileName) };
FieldInformation[] fFiledInfoArray = {fFiledInfo};
var copyresult = copyService.CopyIntoItems(destURL, destinationUrl, fFiledInfoArray, File.ReadAllBytes(fileName), out cResultArray);
var b = copyresult;
}
catch (Exception ex)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误"Object …