Search Results

Search found 847 results on 34 pages for 'simon'.

Page 22/34 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • jQuery live keydown doesn't register until second keydown

    - by Simon
    Hi there, I'm trying to add a class (.active) to a text field once the user starts typing. I got it to work somewhat with the following code, but for some reason the .active class is not applied immediately when the user starts typing, it's only applied after a second letter has been typed. Any ideas? $(document).ready(function() { loginField = $('.field'); loginField.live('keydown', function(){ if ($(this).val()){ $(this).addClass('active'); } }); });

    Read the article

  • HttpWebRequest response produces HTTP 422. Why?

    - by Simon
    Hi there. I'm trying to programmatically send a POST-request to a web-server in order to login an then perform other requests that require a login. This is my code: Encoding.UTF8.GetBytes( String.Format( "login={0}&password={1}&authenticity_token={2}", username, password, token)); //Create HTTP-request for login HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.xxx.xx/xx/xx"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; request.CookieContainer = new CookieContainer(); request.Accept = "application/xml,application/xhtml+xml,text/html; +"q=0.9,text/plain ;q=0.8,image/png,*/*;q=0.5"; request.Referer = "http://www.garzantilinguistica.it/it/session"; request.Headers.Add("Accept-Language", "de-DE"); request.Headers.Add("Origin", "http://www.xxx.xx"); request.UserAgent = "C#"; request.Headers.Add("Accept-Encoding", "gzip, deflate"); After sending the request //Send post request var requestStream = request.GetRequestStream(); requestStream.Write(data, 0, data.Length); requestStream.Flush(); requestStream.Close(); ... I want to get the servers response: //Get Response StreamReader responseStreamReader = new StreamReader( request.GetResponse().GetResponseStream()); //WebException: HTTP 422! string content = responseStreamReader.ReadToEnd(); This piece of code fires the WebException, that tells me the server responded with HTTP 422 (unprocessable entity due to semantic errors) Then I compared (using a TCP/IP sniffers) the requests of my program and the browser (which of course produces a valid POST-request and gets the right response). (1) My program's request: POST /it/session HTTP/1.1 Content-Type: application/x-www-form-urlencoded Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain; q=0.8,image/png,*/*;q=0.5 Referer: http://www.garzantilinguistica.it/it/session Accept-Language: de-DE Origin: http://www.garzantilinguistica.it User-Agent: C# Accept-Encoding: gzip, deflate Host: www.garzantilinguistica.it Content-Length: 111 Expect: 100-continue Connection: Keep-Alive HTTP/1.1 100 Continue [email protected]&password=machivui&authenticity_token=4vLgtwP3nFNg4NeuG4MbUnU7sy4z91Wi8WJXH0POFmg= HTTP/1.1 422 Unprocessable Entity (2) The browser's request: POST /it/session HTTP/1.1 Host: www.garzantilinguistica.it Referer: http://www.garzantilinguistica.it/it/session Accept: application/xml,application/xhtml+xml,text/html;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: de-DE Origin: http://www.garzantilinguistica.it User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de-DE) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Cookie: __utma=244184339.652523587.1275208707.1275208707.1275211298.2; __utmb=244184339.20.10.1275211298; __utmc=244184339; __utmz=244184339.1275208707.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _garzanti2009_session=BAh7CDoPc2Vzc2lvbl9pZCIlZDg4MWZjNjg2YTRhZWE0NDQ0ZTJmMTU2YWY4ZTQ1NGU6EF9jc3JmX3Rva2VuIjFqRWdLdll3dTYwOTVVTEpNZkt6dG9jUCtaZ0o4V0FnV2V5ZnpuREx6QUlZPSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsGOgplcnJvciIVbG9naW4gbm9uIHZhbGlkbwY6CkB1c2VkewY7CFQ%3D--4200fa769898dd156faa49e457baf660cf068d08 Content-Length: 144 Connection: keep-alive authenticity_token=jEgKvYwu6095ULJMfKztocP%2BZgJ8WAgWeyfznDLzAIY%3D&login=thespider14%40hotmail.com&password=machivui&remember_me=1&commit=Entra HTTP/1.1 302 Found Can someone help to understand which part of the request I am missing or what the main difference between the browser's and my request is? Why am I getting that 422?

    Read the article

  • Posting status via Facebook's graph api

    - by Simon R
    In PHP, I am trying to post a status to our Facebook fan page using the graph api, despite following the intructions facebook give, the following code does not seem to update the status. Here is the code; $xPost['access_token'] = "{key}"; $xPost['message'] = "Posting a message test."; $ch = curl_init('https://graph.facebook.com/{page_id}/feed'); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xPost); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_CAINFO, NULL); curl_setopt($ch, CURLOPT_CAPATH, NULL); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); $result = curl_exec($ch); Does anyone know why this code is not working? The access_token is correct.

    Read the article

  • Why does SFINAE not apply to this?

    - by Simon Buchan
    I'm writing some simple point code while trying out Visual Studio 10 (Beta 2), and I've hit this code where I would expect SFINAE to kick in, but it seems not to: template<typename T> struct point { T x, y; point(T x, T y) : x(x), y(y) {} }; template<typename T, typename U> struct op_div { typedef decltype(T() / U()) type; }; template<typename T, typename U> point<typename op_div<T, U>::type> operator/(point<T> const& l, point<U> const& r) { return point<typename op_div<T, U>::type>(l.x / r.x, l.y / r.y); } template<typename T, typename U> point<typename op_div<T, U>::type> operator/(point<T> const& l, U const& r) { return point<typename op_div<T, U>::type>(l.x / r, l.y / r); } int main() { point<int>(0, 1) / point<float>(2, 3); } This gives error C2512: 'point<T>::point' : no appropriate default constructor available Given that it is a beta, I did a quick sanity check with the online comeau compiler, and it agrees with an identical error, so it seems this behavior is correct, but I can't see why. In this case some workarounds are to simply inline the decltype(T() / U()), to give the point class a default constructor, or to use decltype on the full result expression, but I got this error while trying to simplify an error I was getting with a version of op_div that did not require a default constructor*, so I would rather fix my understanding of C++ rather than to just do what works. Thanks! *: the original: template<typename T, typename U> struct op_div { static T t(); static U u(); typedef decltype(t() / u()) type; }; Which gives error C2784: 'point<op_div<T,U>::type> operator /(const point<T> &,const U &)' : could not deduce template argument for 'const point<T> &' from 'int', and also for the point<T> / point<U> overload.

    Read the article

  • Trying to debug a plugin in tuxguitar, need help building the project in Eclipse.

    - by Shawn Simon
    I am not too familiar with java / eclipse but I am trying to debug a plugin in TuxGuitar. The plugin is the gtp plugin which allows reading of guitar pro files. I have imported the main project, TuxGuitar, and the TuxGuitar-gtp plugin. I have all build dependencies configured and the project builds. However, when I debug the app, the plugin is not available. The documentation says plugins are loaded from the share/plugins folder and they are jar files. I tried exporting the gtp plugin as a jar into the share/plugins folder, but it still does not load when I debug. Is there some sort of configuration I need to do in Eclipse? Thanks!

    Read the article

  • English dictionary as txt or xml file with support of synonyms

    - by Simon
    Can someone point me to where I can download English dictionary as a txt or xml file. I am building a simple app for myself and looking for something what I could start using immediately without learning complex API. Support for synonyms would be great, that is it should be easier to retrieve all the synonyms for particular word. It would be absolutely fantastic if dictionary would be listing British and American spelling of the words where they are differ. Even if it would be small dictionary (few 000's words) that's ok, I only need it for small project. I even would be willing to buy one if the price is reasonable, and dictionary is easy to use - simple xml wold be great. Any directions please.

    Read the article

  • Defining a dd/mm/yyyy field within an abstract table model

    - by Simon Andi
    I have defined an abstract table model but one of the columns should house date values as dd/mm/yyyy format not sure how to do this. I have a external global file and have hard coded the dates as dd/mm/yyyy. How can I define this column within my abstract table model so that to only allow only dates having dd/mm/yyyy format. public class OptraderGlobalParameters { public static boolean DEBUG = true; //Set DEBUG = true for Debugging /*=========================*/ /*Table Array For Dividends*/ /*=========================*/ public static String[] columnNames = {"Date", "Dividend", "Actual", "Yield (%)" }; public static Object[][] data = { {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, }; }

    Read the article

  • Facebook multiquery result goes wrong?

    - by Simon
    This is my xml result return from facebook <fql_result_set list="true" xmlns="http://api.facebook.com/1.0/"> <comment> <object_id340982187784 </fql_result_set> <fql_result_set list="true" xmlns="http://api.facebook.com/1.0/"> <fql_result_set_elt list="true"> <fql_result_set_elt_elt key="object_id"340982187784811202784 The comment tag part is ok. After the comments you see the fql_result_set_elt and fql_result_elt_elt, this is the part goes wrong. fql_result_set_elt = like tag fql_result_set_elt_elt = object_id tag or user_id instead of having it on key attribute under fql_result_elt_elt

    Read the article

  • Application of a rule based expert system

    - by simon
    Hi, The company I am working now has developed a Rule-based Expert System. It is a web-based system and supports Flow Chart, Decision Table, Fuzzy Rules and Forward Chaining Rules. It is something like iLog but less complex and powerful. However, one serious problem we are facing now is that we have NO CUSTOMER so far. We have spent 4 yrs to develop that product. Because my company is a start-up and has no reference, no one is confident in our product. Without feedback, we cannot improve our product. I am wondering if we should change our product into SAAS and make it free for people to try, or it has NO MARKET at all. (I will lose my job then..) Please give me some suggestions. Many Thanks!

    Read the article

  • How can I programatically convert SQL data-types to .Net data-types?

    - by Simon
    Can anyone show me a way of converting SQL Server data-types (varchar for example) to .Net data-types (String for example). I'm assuming that automatic conversion is not possible? I have an 'EntityProperty' object and would like it to have an appropriate 'Type' property (string, decimal, int32 etc), at the moment this property is just a string - 'int32' for example. A little background: I'm using SQL DMO in an internal code generation app to query a database and generate a stored procedure based DAL from the database. Being an internal app I can take quite a few shortcuts and make quite a few assumptions. To get the app working at the moment this data-type conversion is handled by a Select Case statement which just converts the types to strings and generates a set of properties based on these strings but I would prefer a little more flexibility in being able to handle the types (use of TypeOf etc). Anyone worked on something similar? I know EF, nHibernate, Subsonic etc could do all this for me but in this case, for various reasons, I am having to roll my own. :)

    Read the article

  • problem with setcookie

    - by Simon
    there is one think, i can't understand anyway:((( when i try to set cookie(it is on line 28 in login.php), browser returns me an error!!! Cannot modify header information - headers already sent by (output started at C:\xampp2\htdocs\video\index.php:9) in C:\xampp2\htdocs\video\login.php on line 28 but on line 9 in index php, i haven't any header!!! there is a tag!!! i cant understand it!!! can somebody tall me why it returns me such error?

    Read the article

  • ASP.NET MVC unit testing

    - by Simon Lomax
    Hi, I'm getting started with unit testing and trying to do some TDD. I've read a fair bit about the subject and written a few tests. I just want to know if the following is the right approach. I want to add the usual "contact us" facility on my web site. You know the thing, the user fills out a form with their email address, enters a brief message and hits a button to post the form back. The model binders do their stuff and my action method accepts the posted data as a model. The action method would then parse the model and use smtp to send an email to the web site administrator infoming him/her that somebody filled out the contact form on their site. Now for the question .... In order to test this, would I be right in creating an interface IDeliver that has a method Send(emailAddress, message) to accept the email address and message body. Implement the inteface in a concrete class and let that class deal with smtp stuff and actually send the mail. If I add the inteface as a parameter to my controller constructor I can then use DI and IoC to inject the concrete class into the controller. But when unit testing I can create a fake or mock version of my IDeliver and do assertions on that. The reason I ask is that I've seen other examples of people generating interfaces for SmtpClient and then mocking that. Is there really any need to go that far or am I not understanding this stuff?

    Read the article

  • Is there an easier way of creating a registry volatile subkey in .net?

    - by Simon
    So far I have the below which is taken from http://www.danielmoth.com/Blog/volatile-registrykey.aspx public static class RegistryHelper { public static RegistryKey CreateVolatileSubKey(RegistryKey rk, string subkey, RegistryKeyPermissionCheck permissionCheck) { var rk2 = rk.GetType(); const BindingFlags bfStatic = BindingFlags.NonPublic | BindingFlags.Static; const BindingFlags bfInstance = BindingFlags.NonPublic | BindingFlags.Instance; rk2.GetMethod("ValidateKeyName", bfStatic).Invoke(null, new object[] { subkey }); rk2.GetMethod("ValidateKeyMode", bfStatic).Invoke(null, new object[] { permissionCheck }); rk2.GetMethod("EnsureWriteable", bfInstance).Invoke(rk, null); subkey = (string)rk2.GetMethod("FixupName", bfStatic).Invoke(null, new object[] { subkey }); if (!(bool)rk2.GetField("remoteKey", bfInstance).GetValue(rk)) { var key = (RegistryKey)rk2.GetMethod("InternalOpenSubKey", bfInstance, null, new[] { typeof(string), typeof(bool) }, null).Invoke(rk, new object[] { subkey, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree }); if (key != null) { rk2.GetMethod("CheckSubKeyWritePermission", bfInstance).Invoke(rk, new object[] { subkey }); rk2.GetMethod("CheckSubTreePermission", bfInstance).Invoke(rk, new object[] { subkey, permissionCheck }); rk2.GetField("checkMode", bfInstance).SetValue(key, permissionCheck); return key; } } rk2.GetMethod("CheckSubKeyCreatePermission", bfInstance).Invoke(rk, new object[] { subkey }); int lpdwDisposition; IntPtr hkResult; var srh = Type.GetType("Microsoft.Win32.SafeHandles.SafeRegistryHandle"); var temp = rk2.GetField("hkey", bfInstance).GetValue(rk); var rkhkey = (SafeHandleZeroOrMinusOneIsInvalid)temp; var getregistrykeyaccess = (int)rk2.GetMethod("GetRegistryKeyAccess", bfStatic, null, new[] { typeof(bool) }, null).Invoke(null, new object[] { permissionCheck != RegistryKeyPermissionCheck.ReadSubTree }); var errorCode = RegCreateKeyEx(rkhkey, subkey, 0, null, 1, getregistrykeyaccess, IntPtr.Zero, out hkResult, out lpdwDisposition); var keyNameField = rk2.GetField("keyName", bfInstance); var rkkeyName = (string)keyNameField.GetValue(rk); if (errorCode == 0 && hkResult.ToInt32() > 0) { var rkremoteKey = (bool)rk2.GetField("remoteKey", bfInstance).GetValue(rk); var hkResult2 = srh.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(IntPtr), typeof(bool) }, null).Invoke(new object[] { hkResult, true }); var key2 = (RegistryKey)rk2.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { hkResult2.GetType(), typeof(bool), typeof(bool), typeof(bool), typeof(bool) }, null).Invoke(new[] { hkResult2, permissionCheck != RegistryKeyPermissionCheck.ReadSubTree, false, rkremoteKey, false }); rk2.GetMethod("CheckSubTreePermission", bfInstance).Invoke(rk, new object[] { subkey, permissionCheck }); rk2.GetField("checkMode", bfInstance).SetValue(key2, permissionCheck); if (subkey.Length == 0) { keyNameField.SetValue(key2, rkkeyName); } else { keyNameField.SetValue(key2, rkkeyName + @"\" + subkey); } key2.Close(); return rk.OpenSubKey(subkey, true); } if (errorCode != 0) rk2.GetMethod("Win32Error", bfInstance).Invoke(rk, new object[] { errorCode, rkkeyName + @"\" + subkey }); return null; } [DllImport("advapi32.dll", CharSet = CharSet.Auto)] private static extern int RegCreateKeyEx(SafeHandleZeroOrMinusOneIsInvalid hKey, string lpSubKey, int reserved, string lpClass, int dwOptions, int samDesigner, IntPtr lpSecurityAttributes, out IntPtr hkResult, out int lpdwDisposition); } Which works but is fairly ugly. Is there a better way?

    Read the article

  • Where do I put jar files in Tomcat 6?

    - by Simon
    I am having trouble getting my JSP page to load a Java class which is in a jar file. The message I get appears to indicate a class not found exception: Jan 6, 2011 12:21:45 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 72 in the jsp file: /xmlloader.jsp FactArray cannot be resolved to a type 69: sourceType = "1"; 70: } 71: 72: FactArray fa = new FactArray(); 73: Fact f; 74: 75: /***********************/ The Type FactArray is one of my classes in a package com.mypackage.fact.FactArray which exists in myjar.jar. myjar.jar is a separate Java project (using NetBeans, but I don't think that's relevant). I include the package in my JSP as follows: <%@ page import="com.mypackage.fact.*" %> I deploy my web site and JSPs into Tomcat 6 as a WAR file. I include myjar.jar in that WAR in WEB-INF/lib but that doesn't work. I tried putting myjar.jar in my tomcat/lib folder, but that doesn't work either. I have bounced the server several times between changes. I have read a whole bunch of questions on here which say "put it in WEB-INF/lib" but that isn't working, so I'm asking my own question. Where do I need to put common JAR files so they get picked up by Tomcat?

    Read the article

  • Regular - Take all numeric characters following a text character

    - by Simon
    Given a string in the format: XXX999999v99 (where X is any alpha character and v is any numeric character and v is a literal v character) how can I get a regex to match the numeric chatacters following the v? So far I've got 'v\d\d' which includes the v but ideally I'd like just the numeric part. As an aside does anyone know of a tool in which you can specify a string to match and have the regex generated? Modifying an existing regex is one thing but I find starting from scratch painful!

    Read the article

  • Datagridview error

    - by Simon
    I have two datagridviews. So for the second one, i just copy-pasted the code from the first and changed where the difference was. But i get an error at the secod data grid when i want to view the result of my sql code. Translated in english the error show something like that there was no value given to at least one required parameter. Please help! private void button1_Click(object sender, EventArgs e) { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=save.mdb"; try { database = new OleDbConnection(connectionString); database.Open(); date = DateTime.Now.ToShortDateString(); string queryString = "SELECT zivila.naziv,(obroki_save.skupaj_kalorij/zivila.kalorij)*100 as Kolicina_v_gramih " + "FROM (users LEFT JOIN obroki_save ON obroki_save.ID_uporabnika=users.ID)" + " LEFT JOIN zivila ON zivila.ID=obroki_save.ID_zivila " + " WHERE users.ID= " + a.ToString(); loadDataGrid(queryString); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } public void loadDataGrid(string sqlQueryString) { OleDbCommand SQLQuery = new OleDbCommand(); DataTable data = null; dataGridView1.DataSource = null; SQLQuery.Connection = null; OleDbDataAdapter dataAdapter = null; dataGridView1.Columns.Clear(); // <-- clear columns SQLQuery.CommandText = sqlQueryString; SQLQuery.Connection = database; data = new DataTable(); dataAdapter = new OleDbDataAdapter(SQLQuery); dataAdapter.Fill(data); dataGridView1.DataSource = data; dataGridView1.AllowUserToAddRows = false; dataGridView1.ReadOnly = true; dataGridView1.Columns[0].Visible = true; } private void Form8_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=save.mdb"; try { database = new OleDbConnection(connectionString); database.Open(); date = DateTime.Now.ToShortDateString(); string queryString = "SELECT skupaj_kalorij " + "FROM obroki_save " + " WHERE users.ID= " + a.ToString(); loadDataGrid2(queryString); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } public void loadDataGrid2(string sqlQueryString) { OleDbCommand SQLQuery = new OleDbCommand(); DataTable data = null; dataGridView2.DataSource = null; SQLQuery.Connection = null; OleDbDataAdapter dataAdapter = null; dataGridView2.Columns.Clear(); // <-- clear columns SQLQuery.CommandText = sqlQueryString; SQLQuery.Connection = database; data = new DataTable(); dataAdapter = new OleDbDataAdapter(SQLQuery); dataAdapter.Fill(data); dataGridView2.DataSource = data; dataGridView2.AllowUserToAddRows = false; dataGridView2.ReadOnly = true; dataGridView2.Columns[0].Visible = true; }

    Read the article

  • Weird Excel bar disgram behaviour

    - by Simon
    Hi I have a very simple question. I wanna have a diagram with the following table Apple 30 40 50 Pears 200 300 400 Bananas 10 20 30 The weird thing, when I try to draw a bar diagram the order of the bars change. So Excel draws me first the Bananas, the the pears and finally the apple bar... Is there anyway to tell Excel 2003 that it keeps the order? Thank you very much

    Read the article

  • Dealing with uncertainty in ORM - Entity Framework CodeOnly

    - by Simon Fox
    This is a bit of a strange one but I've just seen something on twitter which kind of baffled me and I'm interested to know more. Rob Conery tweeted the following a couple of hours ago: Class name of the day: "Maybe<T>". Method of the day: "ToMaybe<T>()". He then went on to offer a Tekpub coupon to anyone who could guess where it came from. He linked to a further tweet which had a clue and from that I worked out that it was Entity Framework Code-Only but while trying to determine the usage someone else answered to which Rob replied ...EF CodeOnly - dealing with uncertainty.... So my question boils down to what exactly is he referring to with uncertainty and how does this fit in to Entity Framework Code-Only?

    Read the article

  • How to create tests for poco objects

    - by Simon G
    Hi, I'm new to mocking/testing and wanting to know what level should you go to when testing. For example in my code I have the following object: public class RuleViolation { public string ErrorMessage { get; private set; } public string PropertyName { get; private set; } public RuleViolation( string errorMessage ) { ErrorMessage = errorMessage; } public RuleViolation( string errorMessage, string propertyName ) { ErrorMessage = errorMessage; PropertyName = propertyName; } } This is a relatively simple object. So my question is: Does it need a unit test? If it does what do I test and how? Thanks

    Read the article

  • Using Linq to group a list of objects into a new grouped list of list of objects

    - by Simon G
    Hi, I don't know if this is possible in Linq but here goes... I have an object: public class User { public int UserID { get; set; } public string UserName { get; set; } public int GroupID { get; set; } } I return a list that may look like the following: List<User> userList = new List<User>(); userList.Add( new User { UserID = 1, UserName = "UserOne", GroupID = 1 } ); userList.Add( new User { UserID = 2, UserName = "UserTwo", GroupID = 1 } ); userList.Add( new User { UserID = 3, UserName = "UserThree", GroupID = 2 } ); userList.Add( new User { UserID = 4, UserName = "UserFour", GroupID = 1 } ); userList.Add( new User { UserID = 5, UserName = "UserFive", GroupID = 3 } ); userList.Add( new User { UserID = 6, UserName = "UserSix", GroupID = 3 } ); I want to be able to run a Linq query on the above list that groups all the users by GroupID. So the out pub will be a list of user lists that contains user (if that makes sense?). So the out put would be something like: GroupedUserList UserList UserID = 1, UserName = "UserOne", GroupID = 1 UserID = 2, UserName = "UserTwo", GroupID = 1 UserID = 4, UserName = "UserFour", GroupID = 1 UserList UserID = 3, UserName = "UserThree", GroupID = 2 UserList UserID = 5, UserName = "UserFive", GroupID = 3 UserID = 6, UserName = "UserSix", GroupID = 3 I've tried using the groupby linq clause but this seems to return a list of keys and its not grouped by correctly: var groupedCustomerList = userList.GroupBy( u => u.GroupID ).ToList(); Any help would be much appreciated. Thanks

    Read the article

  • Postgres column casting...

    - by Simon
    I have a query SELECT assetid, type_code, version, name, short_name, status, languages, charset, force_secure, created, created_userid, updated, updated_userid, published, published_userid, status_changed, status_changed_userid FROM sq_ast WHERE assetid = 7 which doesn't work and throws ERROR: operator does not exist: character varying = integer LINE 4: FROM sq_ast WHERE assetid = 7 I can get it to work by doing SELECT assetid, type_code, version, name, short_name, status, languages, charset, force_secure, created, created_userid, updated, updated_userid, published, published_userid, status_changed, status_changed_userid FROM sq_ast WHERE assetid = '7' Please note the quoting of the 7 in the WHERE clause... I am deploying an huge application and I cannot rewrite the core... similarly I don't want to risk changing the type of the column... I'm no Postgres expert... please help... Is there an option for strict casting of columns???

    Read the article

  • "Dealing with uncertainty" - Entity Framework CodeOnly

    - by Simon Fox
    This is a bit of a strange one but I've just seen something on twitter which kind of baffled me and I'm interested to know more. Rob Conery tweeted the following a couple of hours ago: Class name of the day: "Maybe<T>". Method of the day: "ToMaybe<T>()". He then went on to offer a Tekpub coupon to anyone who could guess where it came from. He linked to a further tweet which had a clue and from that I worked out that it was Entity Framework Code-Only but while trying to determine the usage someone else answered to which Rob replied ...EF CodeOnly - dealing with uncertainty.... So my question boils down to what exactly is he referring to with uncertainty and how does this fit in to Entity Framework Code-Only?

    Read the article

  • Spring.NET & Immediacy CMS (or how to inject to server side controls without using PageHandlerFactor

    - by Simon Rice
    Is there any way to inject dependencies into an Immediacy CMS control using Spring.NET, ideally without having to use to ContextRegistry when initialising the control? Update, with my own answer The issue here is that Immediacy already has a handler defined in web.config that deals with all aspx pages, & so it's not possible add an entry for Spring.NET's PageHandlerFactory in web.config as per a normal webforms app. That rules out making the control implement ISupportsWebDependencyInjection. Furthermore, most of Immediacy's generated pages are aspx pages that don't physically exist on the drive. I have changed the title of the question to reflect this. What I have done to get Dependency Injection working is: Add the usual entries to web.config for Spring.NET as outlined in the documentation, except for the adding the entry to the <httpHandlers> section. In this case I've got my object definitions in Spring.config. Create the following abstract base class that will deal with all of the Dependency Injection work: DIControl.cs public abstract class DIControl : ImmediacyControl { protected virtual string DIName { get { return this.GetType().Name; } } protected override void OnInit(EventArgs e) { if (ContextRegistry.GetContext().GetObject(DIName, this.GetType()) != null) ContextRegistry.GetContext().ConfigureObject(this, DIName); base.OnInit(e); } } For non-immediacy controls, you can make this server side control inherit from Control or whatever subclass of that you like. For any control with which you wish to use with Spring.NET's Inversion of Control container, define it to inherit from DIControl & add the relelvant entry to Spring.config, for example: SampleControl.cs public class SampleControl : DIControl, INamingContainer { public string Text { get; set; } protected string InjectedText { get; set; } public SampleControl() : base() { Text = "Hello world"; } protected override void RenderContents(HtmlTextWriter output) { output.Write(string.Format("{0} {1}", Text, InjectedText)); } } Spring.config <objects xmlns="http://www.springframework.net"> <object id="SampleControl" type="MyProject.SampleControl, MyAssembly"> <property name="InjectedText" value="from Spring.NET" /> </object> </objects> You can optionally override DIName if you wish to name your entry in Spring.config differently from the name of your class. Provided everything's done correctly, you will have the control writing out "Hello world from Spring.NET!" when used in a page. This solution uses Spring.NET's ContextRegistry from within the control, but I would be surprised if there's no way around that for Immediacy at least since the page objects themselves aren't accessible. However, can this be improved at all from a Spring.NET perspective? Is there maybe an Immediacy plugin that already does this that I'm completely unaware of? Or is there an approach that does this in a more elegant way? I'm open to suggestions.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >