Search Results

Search found 44086 results on 1764 pages for 'web filtering'.

Page 126/1764 | < Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >

  • Noob LINQ - reading, filtering XML with XDocument

    - by user316117
    I'm just learning XDocument and LINQ queries. Here's some simple XML (which doesn't look formatted exactly right in this forum in my browser, but you get the idea . . .) <?xml version="1.0" encoding="utf-8"?> <quiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/name XMLFile2.xsd" title="MyQuiz1"> <q_a> <q_a_num>1</q_a_num> <q_>Here is question 1</q_> <_a>Here is the answer to 1</_a> </q_a> <q_a> <q_a_num>2</q_a_num> <q_>Here is question 2</q_> <_a>Here is the answer to 2</_a> </q_a> </quiz> I can iterate across all elements in my XML file and display their Name, Value, and NodeType in a ListBox like this, no problem: XDocument doc = XDocument.Load(sPath); IEnumerable<XElement> elems = doc.Descendants(); IEnumerable<XElement> elem_list = from elem in elems select elem; foreach (XElement element in elem_list) { String str0 = "Name = " + element.Name.ToString() + ", Value = " + element.Value.ToString() + ", Nodetype = " + element.NodeType.ToString(); System.Windows.Controls.Label strLabel = new System.Windows.Controls.Label(); strLabel.Content = str0; listBox1.Items.Add(strLabel); } ...but now I want to add a "where" clause to my query so that I only select elements with a certain name (e.g., "qa") but my element list comes up empty. I tried . . . IEnumerable<XElement> elem_list = from elem in elems where elem.Name.ToString() == "qa" select elem; Could someone please explain what I'm doing wrong? (and in general are there some good tips for debugging Queries?) Thanks in advance!

    Read the article

  • SubSonic generated code and always filtering records

    - by cmroanirgo
    Hi, I have a table called "Users" that has a column called "deleted", a boolean indicating that the user is "Deleted" from the system (without actually deleting it, of course). I also have a lot of tables that have a FK to the Users.user_id column. Subsonic generates (very nicely) the code for all the foreign keys in a similar manner: public IQueryable<person> user { get { var repo=user.GetRepo(); return from items in repo.GetAll() where items.user_id == _user_id select items; } } Whilst this is good and all, is there a way to generate the code in such a way to always filter out the "Deleted" users too? In the office here, the only suggestion we can think of is to use a partial class and extend it. This is obviously a pain when there are lots and lots of classes using the User table, not to mention the fact that it's easy to inadvertently use the wrong property (User vs ActiveUser in this example): public IQueryable<User> ActiveUser { get { var repo=User.GetRepo(); return from items in repo.GetAll() where items.user_id == _user_id and items.deleted == 0 select items; } } Any ideas?

    Read the article

  • Image gallery control for ASP.Net with filtering capabilities

    - by ks78
    I'm writing an ASP.Net application which needs to display a large number of thumbnails, preferably in a paginated format. These thumbnails will be stored on the server's hard disk, but will have their filenames listed in a SQL Server database. What I want to do is to be able to filter the images being displayed based on criteria within the database. I've looked at the NotesForGallery control, which I really like, but it doesn't seem to have a way to do that. --if I'm wrong, please correct me. Are there any other image gallery type controls, preferably free, that can do what I need? I'm hoping someone can recommend a control or solution that will point me in the right direction. Thanks in advance.

    Read the article

  • Report Builder Error (Input string was not in a correct format) when filtering data

    - by JVZ
    Issue: the user is getting an error “The requested list could not be retrieved because the query is not valid or a connection could not be made to the data source.” while trying to filter a reporting using Report Builder 2.0. When you expand the details the message is “Input string was not in a correct format” I verified that when the user clicks to see the filter values the query is being sent to the underlying database (by using profiler). When I build the same report [I'm a server admin] I have no issues and see all the filtered values, which leads me to believe this is a permissions issue. I believe I granted all the correct permissions, see below: Report Server Setup [Project Name] Data Sources Models […other folders] We are using SQL Server 2005. The user belongs to a poweruser domain group which has the following permissions: Home Report Builder View Folders Browser Home/[Project Name] Browser Report Builder View Folders [Data Sources] Browser Content Developer [Models] [Inherit roles from Parent folder] << should be same as [Project Name] folder Report server log is showing the following: w3wp!library!5!04/21/2010-08:47:27:: Call to GetPermissionsAction(/). w3wp!library!a!04/21/2010-08:47:27:: Call to GetPropertiesAction(/, PathBased). w3wp!library!5!04/21/2010-08:47:27:: Call to GetSystemPermissionsAction(). w3wp!library!a!04/21/2010-08:47:27:: Call to ListChildrenAction(/, False). w3wp!library!a!04/21/2010-08:47:27:: Call to GetSystemPropertiesAction(). w3wp!library!a!04/21/2010-08:47:27:: Call to GetSystemPropertiesAction(). w3wp!library!9!04/21/2010-08:47:40:: Call to ListModelPerspectivesAction(). w3wp!library!9!04/21/2010-08:48:22:: Call to GetUserModelAction(//Models/, ). w3wp!library!5!04/21/2010-08:48:45:: Call to GetItemTypeAction(/). w3wp!library!9!04/21/2010-08:48:46:: Call to GetItemTypeAction(/). w3wp!library!5!04/21/2010-08:48:53:: Call to GetItemTypeAction(/). w3wp!library!a!04/21/2010-08:49:21:: Call to ListModelPerspectivesAction(). w3wp!library!b!04/21/2010-08:53:40:: Call to GetUserModelAction(//Models/, ). w3wp!library!5!04/21/2010-08:54:48:: i INFO: Call to RenderFirst( '' ) w3wp!webserver!5!04/21/2010-08:54:48:: i INFO: Processed report. Report='/', Stream='' w3wp!library!9!04/21/2010-08:56:42:: Call to GetItemTypeAction(/). w3wp!library!9!04/21/2010-08:56:42:: Call to GetItemTypeAction(/). w3wp!library!a!04/21/2010-08:56:50:: Call to GetItemTypeAction(/). Any ideas on how to resolve/troubleshoot this issue?

    Read the article

  • Colloborative filtering

    - by Pranay Kumar
    How can i use SVD algorithm in mahout for producing recommendations on explicit binary data-set (eg. a user purchased or not but no specific ratings ) in an e-commerce domain ? Also what algorithms aim at producing recommendations on such binary data-sets ? Thanks in advance. Pranay Kumar, 2nd yr,cse

    Read the article

  • Filtering out emoticons using sed

    - by user349222
    Hello, I have a grep expression using cygwin grep on Win. grep -a "\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u" all_fbs.txt > rockon_fbs.txt Once I identify the emoticon class, however, I want to strip them out of the data. However, the same regexp above within a sed results in a syntax error (yes, I realize I could use /d instead of //g, but this doesn't make a difference, I still get the error.) sed "s/\(\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u\)*//g" The full line is: grep -a "\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u" all_fbs.txt | sed "s/\(\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u\)*//g" | sed "s/^/ROCKON\t/" > rockon_fbs.txt The result is: sed: -e expression #1, char 14: unknown option to `s' I know it's coming from the sed regexp I'm asking about it b/c if I remove that portion of the full line, then I get no error (but, of course, the emoticons are not filtered out). Thanks in advance, Steve

    Read the article

  • Row Source - combo box, filtering what pops up in a combo box by date

    - by primus285
    so I have a combo box that I want to pop up when somebody wants to search by year. It will allow them to see in that combo box only results that happened in a certain year. so far I have something like SELECT DISTINCT Database_New.ASEC FROM Database_New WHERE (((Database_New.Date) >= DateValue('01/01/2001') AND (((Database_New.Date) <= DateValue('12/031/2001'))); or SELECT DISTINCT Database_New.ASEC FROM Database_New WHERE (((Database_New.Date) >= BETWEEN DateValue('01/01/2001') AND DateValue('12/31/2001’))); as you can see, the kicker is that I am already sorting the thing with SELECT DISTINCT under the ASEC field. But I want to filter it one more by year so a whole bunch of ASEC values that didnt happen in that year (and there are quite a few that happen rarely, or would onyl be associeted with one year) do not pop up as avalible. so far I get an error like "Syntax error in query expression '(((Database_New.Date) = DateValue('01/01/2001') AND (((Database_New.Date) <= DateValue('12/031/2001')))' and I am a VBA person, not quite as good at debuggin SQL. Is it something easy? or will it simply not work the way I have it set up.

    Read the article

  • Filtering most out of XML with XSL?

    - by Gnudiff
    I need to transform a lot of XML files (Fedora export) into a different kind of XML. Trying to do it with XSL stylesheets and checking with the msxsl transformer. Supposedly I have xml file like this (assuming there are actually other nodes inside AAA, OBJ, amd all other nodes), Source.XML: <DOC> <AAA> <STUFF>example</STUFF> <OBJ> <OBJVERS id="A1" CREATED="2008-02-18T13:28:08.245Z"/> <OBJVERS id="A2" CREATED="2008-02-19T10:42:41.965Z"/> <OBJVERS id="A13" CREATED="2009-03-16T12:43:11.703Z"/> </OBJ> </AAA> <FFF/> <GGG/> <DDD> <FILE /> </DDD> </DOC> Which I need to look something like this (Target.XML): <MYOBJ> <ELEM>contents of OBJVERS with the biggest id OR creation date (whichever is easier to do) go here</ELEM> <IMAGE> contents of <FILE> node go here</IMAGE> </MYOBJ> The main problem that I have is that since I am new to XSL (and for this particular task do not have enough time to learn it properly) is that I can't understand how to tell XSL processor not to process anything else, I keep getting output from , for example. Update: basically, I solved this problem meanwhile. I will post my own answer and close the question. Update2: OK, Andrew's answer works, too, so I am just accepting it. :)

    Read the article

  • Paging, sorting and filtering in a stored procedure (SQL Server)

    - by Fruitbat
    I was looking at different ways of writing a stored procedure to return a "page" of data. This was for use with the asp ObjectDataSource, but it could be considered a more general problem. The requirement is to return a subset of the data based on the usual paging paremeters, startPageIndex and maximumRows, but also a sortBy parameter to allow the data to be sorted. Also there are some parameters passed in to filter the data on various conditions. One common way to do this seems to be something like this: [Method 1] ;WITH stuff AS ( SELECT CASE WHEN @SortBy = 'Name' THEN ROW_NUMBER() OVER (ORDER BY Name) WHEN @SortBy = 'Name DESC' THEN ROW_NUMBER() OVER (ORDER BY Name DESC) WHEN @SortBy = ... ELSE ROW_NUMBER() OVER (ORDER BY whatever) END AS Row, ., ., ., FROM Table1 INNER JOIN Table2 ... LEFT JOIN Table3 ... WHERE ... (lots of things to check) ) SELECT * FROM stuff WHERE (Row > @startRowIndex) AND (Row <= @startRowIndex + @maximumRows OR @maximumRows <= 0) ORDER BY Row One problem with this is that it doesn't give the total count and generally we need another stored procedure for that. This second stored procedure has to replicate the parameter list and the complex WHERE clause. Not nice. One solution is to append an extra column to the final select list, (SELECT COUNT(*) FROM stuff) AS TotalRows. This gives us the total but repeats it for every row in the result set, which is not ideal. [Method 2] An interesting alternative is given here (http://www.4guysfromrolla.com/articles/032206-1.aspx) using dynamic SQL. He reckons that the performance is better because the CASE statement in the first solution drags things down. Fair enough, and this solution makes it easy to get the totalRows and slap it into an output parameter. But I hate coding dynamic SQL. All that 'bit of SQL ' + STR(@parm1) +' bit more SQL' gubbins. [Method 3] The only way I can find to get what I want, without repeating code which would have to be synchronised, and keeping things reasonably readable is to go back to the "old way" of using a table variable: DECLARE @stuff TABLE (Row INT, ...) INSERT INTO @stuff SELECT CASE WHEN @SortBy = 'Name' THEN ROW_NUMBER() OVER (ORDER BY Name) WHEN @SortBy = 'Name DESC' THEN ROW_NUMBER() OVER (ORDER BY Name DESC) WHEN @SortBy = ... ELSE ROW_NUMBER() OVER (ORDER BY whatever) END AS Row, ., ., ., FROM Table1 INNER JOIN Table2 ... LEFT JOIN Table3 ... WHERE ... (lots of things to check) SELECT * FROM stuff WHERE (Row > @startRowIndex) AND (Row <= @startRowIndex + @maximumRows OR @maximumRows <= 0) ORDER BY Row (Or a similar method using an IDENTITY column on the table variable). Here I can just add a SELECT COUNT on the table variable to get the totalRows and put it into an output parameter. I did some tests and with a fairly simple version of the query (no sortBy and no filter), method 1 seems to come up on top (almost twice as quick as the other 2). Then I decided to test probably I needed the complexity and I needed the SQL to be in stored procedures. With this I get method 1 taking nearly twice as long as the other 2 methods. Which seems strange. Is there any good reason why I shouldn't spurn CTEs and stick with method 3? UPDATE - 15 March 2012 I tried adapting Method 1 to dump the page from the CTE into a temporary table so that I could extract the TotalRows and then select just the relevant columns for the resultset. This seemed to add significantly to the time (more than I expected). I should add that I'm running this on a laptop with SQL Server Express 2008 (all that I have available) but still the comparison should be valid. I looked again at the dynamic SQL method. It turns out I wasn't really doing it properly (just concatenating strings together). I set it up as in the documentation for sp_executesql (with a parameter description string and parameter list) and it's much more readable. Also this method runs fastest in my environment. Why that should be still baffles me, but I guess the answer is hinted at in Hogan's comment.

    Read the article

  • How and where to store user uploaded files in high traffic web farm scenario website?

    - by Inam Jameel
    i am working on a website which deploy on web farms to serve high traffic. where should i store user uploaded files? is it wise to store uploaded files in the file system of the same website and synchronize these files in all web servers(web farm)? or should i use another server to store all uploaded files in this server to store files in a central location? if separate file server will be a better choice, than how can i pass files from web server to that file server efficiently? or should i upload files directly to that file server?

    Read the article

  • There is an error in XML document... When calling to web service

    - by Sigurjón Guðbergsson
    I have created a web service and a function in it that should return a list of 11thousand records retreived from a pervasive database Here is my function in the web service. [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class BBI : System.Web.Services.WebService { [WebMethod] public List<myObject> getAll() { List<myObject> result = new List<myObject>(); PsqlConnection conn = new PsqlConnection("Host=soemthing;Port=something;Database=something;Encoding=IBM861"); conn.Open(); string strSql = "select 0, 1, 2, 3, 4, 5 from something"; PsqlCommand DBCmd = new PsqlCommand(strSql, conn); PsqlDataReader myDataReader; myDataReader = DBCmd.ExecuteReader(); while (myDataReader.Read()) { myObject b = new myObject(); b.0 = Convert.ToInt32(myDataReader[0].ToString()); b.1 = myDataReader[1].ToString(); b.2 = myDataReader[2].ToString(); b.3 = myDataReader[3].ToString(); b.4 = myDataReader[4].ToString(); b.5 = myDataReader[5].ToString(); result.Add(b); } conn.Close(); myDataReader.Close(); return result; } } Then i add web reference to this web service in my client program and call the reference BBI. Then i call to the getAll function and get the error : There is an error in XML document (1, 63432). public List<BBI.myObject> getAll() { BBI.BBI bbi = new BBI.BBI(); List<BBI.myObject> allBooks = bbi.getAll().OfType<BBI.myObject>().ToList(); return allBooks; } Here is the total exception detail System.InvalidOperationException was unhandled by user code Message=There is an error in XML document (1, 71897). Source=System.Xml StackTrace: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at BBI.BBI.getAllBooks() in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vefur\73db60db\a4ee31dd\App_WebReferences.jl1r8jv6.0.cs:line 252 at webServiceFuncions.getAllBooks() in c:\Documents and Settings\forritari\Desktop\Vefur - Nýr\BBI\trunk\Vefur\App_Code\webServiceFuncions.cs:line 59 InnerException: System.Xml.XmlException Message='', hexadecimal value 0x01, is an invalid character. Line 1, position 71897. Source=System.Xml LineNumber=1 LinePosition=71897 SourceUri="" StackTrace: at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args) at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, StringBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType) at System.Xml.XmlTextReaderImpl.ParseCharRefInline(Int32 startPos, Int32& charCount, EntityType& entityType) at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars) at System.Xml.XmlTextReaderImpl.ParseText() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Xml.XmlReader.ReadElementString() at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderBBI.Read2_Book(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderBBI.Read20_getAllBooksResponse() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer35.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) InnerException: The database records are containing all kind of strange symbols, for example ¤rmann Kr. Einarsson and Tv” ‘fint˜ri Can someone see what im doing wrong here?

    Read the article

  • filtering directly and indirectly connected things from list

    - by Andreas Romeyke
    Hello, if you have a function "test a b" which returns true if a and b are connected directly and if you have a given unordered list of things, what would be an elegant and fast solution to filter all connected things from given list? Example: let test a b = let diff = a - b in diff == 0 ;; let lst = [4;1;7;3;8;9;2;0] ;; filter_connected 2 lst ;; - [4;1;3;2;0] Any hints?

    Read the article

  • How does this Singleton Web Class persists session data, even though session is not updated in the p

    - by Micah Burnett
    Ok, I've got this singleton-like web class which uses session to maintain state. I initially thought I was going to have to manipulate the session variables on each "set" so that the new values were updated in the session. However I tried using it as-is, and somehow, it remembers state. For example, if run this code on one page: UserContext.Current.User.FirstName = "Micah"; And run this code in a different browser tab, FirstName is displayed correctly: Response.Write(UserContext.Current.User.FirstName); Can someone tell me (prove) how this data is getting persisted in the session? Here is the class: using System; using System.Collections.Generic; using System.Linq; using System.Web; public class UserContext { private UserContext() { } public static UserContext Current { get { if (System.Web.HttpContext.Current.Session["UserContext"] == null) { UserContext uc = new UserContext(); uc.User = new User(); System.Web.HttpContext.Current.Session["UserContext"] = uc; } return (UserContext)System.Web.HttpContext.Current.Session["UserContext"]; } } private string HospitalField; public string Hospital { get { return HospitalField; } set { HospitalField = value; ContractField = null; ModelType = null; } } private string ContractField; public string Contract { get { return ContractField; } set { ContractField = value; ModelType = string.Empty; } } private string ModelTypeField; public string ModelType { get { return ModelTypeField; } set { ModelTypeField = value; } } private User UserField; public User User { get { return UserField; } set { UserField = value; } } public void DoSomething() { } } public class User { public int UserId { get; set; } public string FirstName { get; set; } }

    Read the article

  • Help filtering childs

    - by lidermin
    Hello, I have this jquery code: $(".button-banc").hover(function() { $(".button-banc img") .animate({ top: "-21px" }, 200).animate({ top: "-17px" }, 200) // first jump .animate({ top: "-19px" }, 100).animate({ top: "-17px" }, 100) // second jump .animate({ top: "-18px" }, 100).animate({ top: "-17px" }, 100); // the last jump }); The effect I want is: when you pass the mouse over an image this image should jump a bit. The problem is that I got "some" images with the class "button-banc" and I want this behaive: When you pass the mouse over, "only the actual image" should jump. The problem is that with the code I posted, every image jumps. How can I achieve this, please help; I want to make a generic way, so that if I add images with the class, they also behaive like that. Thanks.

    Read the article

  • Filtering custom fields on wordpress admin page

    - by Kyril
    I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom fields that will later be read from the template. The plugin adds an additional meta box to the "Edit Post" screen which is responsible for manipulating these values. My problem is that the custom fields generated by the plugin also show up in the "Custom Fields" box. Ideally I would like for the custom fields generated by the plugin to be managed separately from any other custom fields for that same post/page. Is there a way that I can filter fields specific to my plugin to prevent them from being displayed in the "Custom Fields" box? I have yet to locate any action or filter that will let me capture and manipulate those values before they are rendered on "Edit Post".

    Read the article

  • How does this Singleton-like web class persists session data, even though session is not updated in

    - by Micah Burnett
    Ok, I've got this singleton-like web class which uses session to maintain state. I initially thought I was going to have to manipulate the session variables on each "set" so that the new values were updated in the session. However I tried using it as-is, and somehow, it remembers state. For example, if run this code on one page: UserContext.Current.User.FirstName = "Micah"; And run this code in a different browser tab, FirstName is displayed correctly: Response.Write(UserContext.Current.User.FirstName); Can someone tell me (prove) how this data is getting persisted in the session? Here is the class: using System; using System.Collections.Generic; using System.Linq; using System.Web; public class UserContext { private UserContext() { } public static UserContext Current { get { if (System.Web.HttpContext.Current.Session["UserContext"] == null) { UserContext uc = new UserContext(); uc.User = new User(); System.Web.HttpContext.Current.Session["UserContext"] = uc; } return (UserContext)System.Web.HttpContext.Current.Session["UserContext"]; } } private string HospitalField; public string Hospital { get { return HospitalField; } set { HospitalField = value; ContractField = null; ModelType = null; } } private string ContractField; public string Contract { get { return ContractField; } set { ContractField = value; ModelType = string.Empty; } } private string ModelTypeField; public string ModelType { get { return ModelTypeField; } set { ModelTypeField = value; } } private User UserField; public User User { get { return UserField; } set { UserField = value; } } public void DoSomething() { } } public class User { public int UserId { get; set; } public string FirstName { get; set; } } I added this to a watch, and can see that the session variable is definitely being set somewhere: (UserContext)System.Web.HttpContext.Current.Session["UserContext"]; As soon as a setter is called the Session var is immediately updated: set { HospitalField = value; //<--- here ContractField = null; ModelType = null; }

    Read the article

  • Building an external list while filtering in LINQ

    - by Khnle
    I have an array of input strings that contains either email addresses or account names in the form of domain\account. I would like to build a List of string that contains only email addresses. If an element in the input array is of the form domain\account, I will perform a lookup in the dictionary. If the key is found in the dictionary, that value is the email address. If not found, that won't get added to the result list. The code below will makes the above description clear: private bool where(string input, Dictionary<string, string> dict) { if (input.Contains("@")) { return true; } else { try { string value = dict[input]; return true; } catch (KeyNotFoundException) { return false; } } } private string select(string input, Dictionary<string, string> dict) { if (input.Contains("@")) { return input; } else { try { string value = dict[input]; return value; } catch (KeyNotFoundException) { return null; } } } public void run() { Dictionary<string, string> dict = new Dictionary<string, string>() { { "gmail\\nameless", "[email protected]"} }; string[] s = { "[email protected]", "gmail\\nameless", "gmail\\unknown" }; var q = s.Where(p => where(p, dict)).Select(p => select(p, dict)); List<string> resultList = q.ToList<string>(); } While the above code works (hope I don't have any typo here), there are 2 problems that I do not like with the above: The code in where() and select() seems to be redundant/repeating. It takes 2 passes. The second pass converts from the query expression to List. So I would like to add to the List resultList directly in the where() method. It seems like I should be able to do so. Here's the code: private bool where(string input, Dictionary<string, string> dict, List<string> resultList) { if (input.Contains("@")) { resultList.Add(input); //note the difference from above return true; } else { try { string value = dict[input]; resultList.Add(value); //note the difference from above return true; } catch (KeyNotFoundException) { return false; } } } The my LINQ expression can be nicely in 1 single statement: List<string> resultList = new List<string>(); s.Where(p => where(p, dict, resultList)); Or var q = s.Where(p => where(p, dict, resultList)); //do nothing with q afterward Which seems like perfect and legal C# LINQ. The result: sometime it works and sometime it doesn't. So why doesn't my code work reliably and how can I make it do so?

    Read the article

  • What is a Web Framework ? How does it compare with LAMP

    - by Nishant
    I started web development in LAMP/WAMP and it was logical to me . There is a Web Server program called Apache which does the networking part of setting up a service on port 80 ( common port ) . If the request is regular HTML it uses the HTTP headers to transport files .And if the request for the file is a PHP one , it has a mod_php with which Apache invokes the PHP interpreter to process the file and it gives back HTML which is again transferred as usual HTML . Now the question is what is a Web Framework ? I came across Python based website creation and there is Flask . What is a flask , how does it compare with LAMP . Further are DJango / Ruby on Rails different from flask ? Can someone answer me and also give some good places to read on these .Thanks for your answers in advance . Further is things like LAMP slower than the common FRAMEWORKS because they claimn easy deplyment fo web apps .

    Read the article

  • Filtering and copying with PowerShell

    - by Bergius
    In my quest to improve my PowerShell skills, here's an example of an ugly solution to a simple problem. Any suggestions how to improve the oneliner are welcome. Mission: trim a huge icon library down to something a bit more manageable. The original directory structure looks like this: /Apps and Utilities /Compile /32 Bit Alpha png /Compile 16 n p.png /+ 10 or more files /+ 5 more formats with 10 or more files each /+ 20 or so icon names /+ 22 more categories I want to copy the 32 Bit Alpha pngs and flatten the directory structure a bit. Here's my quick and very dirty solution: $dest = mkdir c:\icons; gci -r | ? { $_.Name -eq '32 Bit Alph a png' } | % { mkdir ("$dest\" + $_.Parent.Parent.Name + "\" + $_.Parent.Name); $_ } | gci | % { cp $_. FullName -dest ("$dest\" + $_.Directory.Parent.Parent + "\" + $_.Directory.Parent) } Not nice, but it solved my problem. Resulting structure: /Apps and Utilities /Compile /Compile 16 n p.png /etc /etc /etc How would you do it?

    Read the article

  • use awk to identify multi-line record and filtering

    - by nanshi
    I need to process a big data file that contains multi-line records, example input: 1 Name Dan 1 Title Professor 1 Address aaa street 1 City xxx city 1 State yyy 1 Phone 123-456-7890 2 Name Luke 2 Title Professor 2 Address bbb street 2 City xxx city 3 Name Tom 3 Title Associate Professor 3 Like Golf 4 Name 4 Title Trainer 4 Likes Running Note that the first integer field is unique and really identifies a whole record. So in the above input I really have 4 records although I dont know how many lines of attributes each records may have. I need to: - identify valid record (must have "Name" and "Title" field) - output the available attributes for each valid record, say "Name", "Title", "Address" are needed fields. Example output: 1 Name Dan 1 Title Professor 1 Address aaa street 2 Name Luke 2 Title Professor 2 Address bbb street 3 Name Tom 3 Title Associate Professor So in the output file, record 4 is removed since it doen't have the "Name" field. Record 3 doesn't have Address field but still being print to the output since it is a valid record that has "Name" and "Title". Can I do this with awk? But how do i identify a whole record using the first "id" field on each line? Thanks a lot to the unix shell script expert for helping me out! :)

    Read the article

  • Filtering on a left join in SQLalchemy

    - by Adam Ernst
    Using SQLalchemy I want to perform a left outer join and filter out rows that DO have a match in the joined table. I'm sending push notifications, so I have a Notification table. This means I also have a ExpiredDeviceId table to store device_ids that are no longer valid. (I don't want to just delete the affected notifications as the user might later re-install the app, at which point the notifications should resume according to Apple's docs.) CREATE TABLE Notification (device_id TEXT, time DATETIME); CREATE TABLE ExpiredDeviceId (device_id TEXT PRIMARY KEY, expiration_time DATETIME); Note: there may be multiple Notifications per device_id. There is no "Device" table for each device. So when doing SELECT FROM Notification I should filter accordingly. I can do it in SQL: SELECT * FROM Notification LEFT OUTER JOIN ExpiredDeviceId ON Notification.device_id = ExpiredDeviceId.device_id WHERE expiration_time == NULL But how can I do it in SQLalchemy? sess.query( Notification, ExpiredDeviceId ).outerjoin( (ExpiredDeviceId, Notification.device_id == ExpiredDeviceId.device_id) ).filter( ??? ) Alternately I could do this with a device_id NOT IN (SELECT device_id FROM ExpiredDeviceId) clause, but that seems way less efficient.

    Read the article

< Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >