Search Results

Search found 11 results on 1 pages for 'andyc'.

Page 1/1 | 1 

  • Multi-statement Table Valued Function vs Inline Table Valued Function

    - by AndyC
    ie: CREATE FUNCTION MyNS.GetUnshippedOrders() RETURNS TABLE AS RETURN SELECT a.SaleId, a.CustomerID, b.Qty FROM Sales.Sales a INNER JOIN Sales.SaleDetail b ON a.SaleId = b.SaleId INNER JOIN Production.Product c ON b.ProductID = c.ProductID WHERE a.ShipDate IS NULL GO versus: CREATE FUNCTION MyNS.GetLastShipped(@CustomerID INT) RETURNS @CustomerOrder TABLE (SaleOrderID INT NOT NULL, CustomerID INT NOT NULL, OrderDate DATETIME NOT NULL, OrderQty INT NOT NULL) AS BEGIN DECLARE @MaxDate DATETIME SELECT @MaxDate = MAX(OrderDate) FROM Sales.SalesOrderHeader WHERE CustomerID = @CustomerID INSERT @CustomerOrder SELECT a.SalesOrderID, a.CustomerID, a.OrderDate, b.OrderQty FROM Sales.SalesOrderHeader a INNER JOIN Sales.SalesOrderHeader b ON a.SalesOrderID = b.SalesOrderID INNER JOIN Production.Product c ON b.ProductID = c.ProductID WHERE a.OrderDate = @MaxDate AND a.CustomerID = @CustomerID RETURN END GO Is there an advantage to using one over the other? Is there certain scenarios when one is better than the other or are the differences purely syntactical? I realise the 2 example queries are doing different things but is there a reason I would write them in that way? Reading about them and the advantages/differences haven't really been explained. Thanks

    Read the article

  • Faster way to perform checks on method arguments

    - by AndyC
    This is mostly just out of curiosity, and is potentially a silly question. :) I have a method like this: public void MyMethod(string arg1, string arg2, int arg3, string arg4, MyClass arg5) { // some magic here } None of the arguments can be null, and none of the string arguments can equal String.Empty. Instead of me having a big list of: if(arg1 == string.Empty || arg1 == null) { throw new ArgumentException("issue with arg1"); } is there a quicker way to just check all the string arguments? Apologies if my question isn't clear. Thanks!

    Read the article

  • Deserialized xml - check if has child nodes without knowing specific type

    - by AndyC
    I have deserialized an xml file into a C# object and have an "object" containing a specific node I have selected from this file. I need to check if this node has child nodes. I do not know the specific type of the object at any given time. At the moment I am just re-serializing the object into a string, and loading it into an XmlDocument before checking the HasChildNodes property, however when I have thousands of nodes to check this is extremely resource intensive and slow. Can anyone think of a better way I can check if the object I have contains child nodes? Many thanks :)

    Read the article

  • Give app.config another name after build?

    - by AndyC
    As you all know, when you build a project with an app.config file it gets copied to the bin directory and renamed $(targetFileName).config. Is it possible for it to be called something else? For example if my executable is called myApplication.exe, can I have the config file called settings.config as opposed to myApplication.exe.config? Cheers

    Read the article

  • xmlserializer throwing InvalidOperationException

    - by AndyC
    I have an XmlSerializer object, and I have added 2 event handlers to the UnknownElement and UnknownAttribute events, as below: XmlSerializer xs = new XmlSerialiser(typeof(MyClass)); xs.UnknownAttribute += new XmlAttributeEventHandler(xs_UnknownAttribute); xs.UnknownElement += new XmlElementEventHandler(xs_UnknownAttribute); Each of these event handlers basically do the same thing, they print out the node name or the attribute name causing the issue. But for some reason, an InvalidOperationException is getting thrown saying there is an error in the xml document with . I thought these errors would be caught by my events?

    Read the article

  • Taking 2 attributes from XElement to create a dictionary LINQ

    - by AndyC
    I'm trying to take one attribute to use as the key, and another to use as the value. If I use (xDoc is an XDocument object in the example): Dictionary<string, XElement> test = xDoc.Descendants() .Where<XElement>(t => t.Name == "someelement") .ToDictionary<XElement, string>(t => t.Attribute("myattr").Value.ToString()); I get a dictionary with the myattr value as key (which is what I want) but the entire XElement object as the value. What I want to do, is to select a second attribute to set as the value property on each dictionary item, but can't seem to figure that out. Is it possible to do all of this in 1 Linq statement? Curiousity has caught me! Cheers!

    Read the article

  • Stop node containing subnodes and text in schema

    - by AndyC
    If I have some xml like this: <mynode> <mysubnode> <mysubsubnode>hello world</mysubsubnode> some more text </mysubnode> </mynode> As you can see, mysubnode contains both a subnode and some text data. What I want to know is, is it possible to prevent this happening in a schema? I don't want nodes to contain subnodes and text, just subnodes or text. Is there an option in my xsd I can specify to force this? My program to that uses this xml is written in .NET, so I'll tag it as well incase there's anything of use in .net that I can utilise for this, though I'd much rather that the issue was fixed in the schema itself. Cheers

    Read the article

  • Bind event to a div appearing

    - by AndyC
    Can I create an event so I can execute some javascript whenever an element with a specific ID becomes visible or appears on the page? The element comes from a remote resource (so isn't in MY html code but appears on page load) and I'd like some code to run when it appears (and only if it appears, it may not appear every load). Thanks!

    Read the article

  • Lambda "if" statement?

    - by AndyC
    I have 2 objects, both of which I want to convert to dictionarys. I use toDictionary<(). The lambda expression for one object to get the key is (i = i.name). For the other, it's (i = i.inner.name). In the second one, i.name doesn't exist. i.inner.name ALWAYS exists if i.name doesn't. Is there a lambda expression I can use to combine these two? Basically to read as: "if i.name exists then set id to i.name, else set id to i.inner.name". Many thanks.

    Read the article

  • Taking item from string array that *might* be there

    - by AndyC
    Hi all, I have a string array, and it may contain an element with the text "mytext" within the string. eg: mystringarray { [0] => "hello world"; [1] => "some of mytext"; } I also have an array that doesn't have the mytext text in it. mystringarray { [0] => "hello world"; [1] => "some of notmy"; } My problem is when I use: string mytextdata = mystringarray.Single<string>(t => t.Contains("mytext")).ToString(); I get an exception for the second array as it can't find an element that matches the expression. Is there a quick way I can edit this one line to not throw an exception if it finds nothing, and instead just ignore? I have a lot of these lines and I don't want to have to wrap each in an if statement. Apologies if question isn't clear.

    Read the article

1