我正在使用LINQ在单个短语上搜索多个字段,而我正在使用Contains()它.直到今天,当我注意到find方法无法正常工作时.
所以我希望能够搜索有匹配的每个字段.我已经在谷歌和SO上做了一些搜索并找到了使用建议Any()?有没有人有什么建议?
var l = _getData().Select(_marshallData).ToList();
return l.Where(x => x.Name.Contains(what) || x.Pumpkin.Contains(what) || x.Orange.Contains(what) || x.Tomato.Contains(what)).ToList();
Run Code Online (Sandbox Code Playgroud)
请原谅愚蠢的字段名称,我必须更改它们以保密.
我在Visual Studio 2010中有一个包含6个项目的解决方案(1个Web应用程序,4个c#类库,1个c#控制台应用程序).
控制台应用程序是我的测试工具,用它来测试外部Web服务,从我的其他库中的方法输出和一般实验.此测试控制台应用程序只有一个依赖于另一个项目依赖项,一个C#库.
引用的C#库非常简单:
namespace GowallaAPI
{
public class Gowalla
{
private static readonly ILog log = LogManager.GetLogger(typeof(Gowalla));
public SpotsInRadius GetGowallaSpotsInRadius(decimal lat, decimal lon, int radius) {
//snip
}
//other methods removed for brevity//
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的控制台应用程序中添加了一个项目引用:

我也右键点击了参考文献并选择了添加参考...

然后,我去了我的控制台应用程序并添加了;
using Gowalla;
Run Code Online (Sandbox Code Playgroud)
然后点击构建.我明白了:
找不到类型或命名空间名称'Gowalla'(您是否缺少using指令或程序集引用?)
我完全不知所措.我有:
在Gowalla玩一个构造函数而不是:
public Gowalla(){
} ......没有任何效果!
谁能看到明显的东西?我是完全愚蠢的吗?我已经在这几个小时了,我很想知道这是否是一个经典的"木树林"时刻......
帮助赞赏.
编辑1:这是从Reflector公开的Gowalla.dll:

答案:在@ gov有用的建议删除GowallaAPI库并尝试添加其他东西之后我做了并开始添加GowallaAPI库中的旧代码.一切顺利,直到我添加:
private static readonly ILog log = LogManager.GetLogger(typeof(Gowalla));
Run Code Online (Sandbox Code Playgroud)
log4net出于某种奇怪的原因不断抛出构建.唉,在删除该行(对log4net的引用仍然存在)之后,该项目在此后构建并完美运行.感谢@gov让我走上了正确的道路!:d
我和ASMX Web服务无法使用.我们争吵.她提出了我们过去的论点.这是一种痛苦.我们的关系在岩石上!
我有一个ASMX Web服务,我没有使用Newtonsoft库进行序列化(如下所述:http://encosia.com/2011/04/13/asp-net-web-services-mistake-manual-json - 序列化/).它看起来像这样:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string[] GetCitiesWithState(string isoalpha2, string prefixText)
{
var dict = AtomicCore.CityObject.GetCitiesInCountryWithStateAutocomplete(isoalpha2, prefixText);
string[] cities = dict.Values.ToArray();
return cities;
}
Run Code Online (Sandbox Code Playgroud)
够简单吧?它在搜索时返回new:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<string>New Orleans, Louisiana</string>
<string>New York, New York</string>
</ArrayOfString>
Run Code Online (Sandbox Code Playgroud)
我期待JSON,但经过一些阅读后,似乎我不应该尝试序列化输出 - 它应该恰好发生吗?无论如何,所以我在前端有以下JQuery:
$('#<%=txtCity.ClientID%>').autocomplete('<%=ResolveUrl("~/AtomicService/Assets.asmx/GetCitiesWithState")%>', {
dataType: 'json',
httpMethod: 'POST',
contentType: 'application/json; charset=utf-8',
parse: function (data) {
var rows = new Array();
for (var i = 0; i < data.d.length; …Run Code Online (Sandbox Code Playgroud) 我正在考虑在应用程序中使用Adam Shaw优秀的Fullcalendar.然而,他们要求多年作为观点,多个月作为观点.我无法立即看到如何定制Fullcalendar来实现这一目标.
我可以看到AvailableViews(http://arshaw.com/fullcalendar/docs/views/Available_Views/)可以得到答案,但不幸的是文档没有说明为什么如果有人希望扩展这个,接下来的步骤.
关于从哪里开始寻找或任何代码片段的建议将不胜感激.
一如既往的帮助表示赞赏.
stackoverflow的第一次用户,但我已经在Coding Horror上进行了开发.
我遇到了上述错误,令人头疼.我安装了ELMAH和Google Analytics,随着网站流量的增加,我看到此错误的次数也增加了.
我已尽最大努力遵循Microsoft的原则:http://msdn.microsoft.com/en-us/library/ms971481.aspx在整个开发过程中,我根据多个建议来源尽可能地优化了我的代码网络.
我在公共类中有我的SqlConnection;
Public Class pitstop
Public Shared oConn As New System.Data.SqlClient.SqlConnection
Public Shared Sub doConnect()
If oConn.State = ConnectionState.Closed Then
oConn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("pitstopConnectionString").ConnectionString
oConn.Open()
End If
End Sub
Public Shared Sub doGarbage()
oConn.Dispose()
End Sub
' /// other code ///
End Class
Run Code Online (Sandbox Code Playgroud)
在我的主要应用程序页面中,我做了同样的事情:
Private Sub doPump()
pitstop.doConnect()
Dim cmd As New System.Data.SqlClient.SqlCommand("doGetCategory", pitstop.oConn)
Dim dt As New DataTable
Dim dr As SqlDataReader
cmd.Parameters.Add("@cat", SqlDbType.Int)
cmd.Parameters("@cat").Value = CType(Request.QueryString("id"), Integer)
cmd.CommandType = CommandType.StoredProcedure
dr …Run Code Online (Sandbox Code Playgroud) 我有一个名为CookieMonster的类,其目的是简单地根据传递给它的3个参数创建一个cookie.Cookie名称,Cookie名称 - 值对和Cookie到期日期.
我已经尝试过List(of T)和Array以及StringCollection,但我不确定哪个是最好的传递名称 - 值对并将该信息提供给类.
理想情况下,我希望能够做到这样的事情:
Dim l As New List(Of String)
l.Add("name", "value")
l.Add("name", "value")
Dim c as New CookieMonster()
c.Name = "My New Cookie"
c.Values = l
c.Expires = Date.Now()
Run Code Online (Sandbox Code Playgroud)
有没有人有任何建议或代码片段发送给我的路上?
帮助赞赏和欢迎.
谢谢
我写了一个看起来像这样的ASMX服务;
namespace AtomicService
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class Validation : WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string IsEmailValid(string email)
{
Dictionary<string, string> response = new Dictionary<string, string>();
response.Add("Response", AtomicCore.Validation.CheckEmail(email).ToString());
return JsonConvert.SerializeObject(response, Formatting.Indented);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Newtonsoft.Json库来提供JsonConvert.SerializeObject功能.当在Fiddler中调用或通过我的Jquery访问时,我收到此响应:

此警报的代码是:
$(document).ready(function () {
$.ajax({
type: "POST",
url: "http://127.0.0.1/AtomicService/Validation.asmx/IsEmailValid",
data: "{'email':'dooburt@gmail.com'}",
contentType: "application/json",
dataType: "json",
success: function (msg) {
if (msg["d"].length > 0) {
alert("fish");
}
alert("success: " + msg.d);
},
error: function (msg) {
alert("error");
} …Run Code Online (Sandbox Code Playgroud) 我有以下ImageObject类:
public class ImageObject
{
public static Image CropImage(Image img, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(img);
Bitmap target = new Bitmap(cropArea.Width, cropArea.Height);
using(Graphics g = Graphics.FromImage(target))
{
g.DrawImage(bmpImage, new Rectangle(0, 0, target.Width, target.Height), cropArea, GraphicsUnit.Pixel);
g.Dispose();
}
return (Image)target;
}
public static Image ResizeImage(Image imgToResize, Size size)
{
int sourceWidth = imgToResize.Width;
int sourceHeight = imgToResize.Height;
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;
nPercentW = ((float)size.Width / (float)sourceWidth);
nPercentH = ((float)size.Height / (float)sourceHeight); …Run Code Online (Sandbox Code Playgroud) 所以,我已经打了几天这个,我很难过,解决它的最佳方法是什么.我正在使用HAPI的Waterline/dogwater并试图做一些广泛的事情: -
wardrobe.find({WardrobeId: 5}).then(function(clothes) {
//got my clothes in my wardrobe.
clothes.find({Type: 'trousers'},{Kind: 'nice ones'}).then(function(trousers) {
//got my nice trousers
_.each(trousers, function(trouser) {
//logic to see if these are my pink trousers
console.log('color?', trouser.color);
});
console.log('ding');
});
});
Run Code Online (Sandbox Code Playgroud)
我遇到的麻烦是代码总是ding在输出裤子颜色之前.这是因为,据我所知,_.each将使代码异步.我试图介绍Promises(蓝鸟),但没有运气.我甚至查看了生成器(Co),但我的节点版本在v0.11之前修复.
我想在其中执行一些数据库查找_.each,将这些结果(如果有的话)返回到trouser对象,然后可以返回: -
wardrobe.find({WardrobeId: 5}).then(function(clothes) {
//got my clothes in my wardrobe.
clothes.find({Type: 'trousers'},{Kind: 'nice ones'}).then(function(trousers) {
//got my nice trousers
_.each(trousers, function(trouser) {
//logic to see if these are my pink trousers
db.colors.find({Color: trouser.color}).then(function(color) { …Run Code Online (Sandbox Code Playgroud) 我知道我的问题看起来有点像"土拨鼠可以吃多少木头",请原谅......
我有一个带复选框的转发器.这个转发器中有很多行 - 我从来不知道有多少行 - 我想在任何时候只检查一个复选框.如果用户更改了选中的复选框,则取消选中任何预先存在的检查,从而保持单个选中的复选框.
我正在使用VB,但很容易移植任何C#.我想使用JQuery.我一直在寻找谷歌,但似乎只是找到所有已检查,所有未经检查的系统.
有什么建议?