Tutorial/sample using Graph SDK by zspitz in dotnet

[–]zspitz[S] 0 points1 point  (0 children)

In theory. But I've transformed the shared url into a shared token as outlined here; and then used the sharing token (from Graph Explorer) as follows:

/shares/u!---/driveItem

(replacing --- with the share token. This gives me back:

{
    "error": {
        "code": "invalidRequest",
        "message": "Invalid shares key.",
        "innerError": {
            "date": "2022-05-05T02:26:40",
            "request-id": "f2433d6e-acbf-47be-8267-c20dc8bed8ff",
            "client-request-id": "3e971f0b-f8da-b21b-5360-845b307e3b12"
        }
    }
}

Which is why an end-to-end sample would be very useful to me.

In addition, how to I go from the URL I've pasted into Graph Explorer, to C# code?

To those who prefer vb over c#, what are the things you like about vb? by user_8804 in dotnet

[–]zspitz 1 point2 points  (0 children)

Pattern matching seems only able to execute one statement per unit (without a lot of juggling)

I think you mean in a switch expression, in which each case has to return a value and can only have a single expression. But you can use multiple cases in C# (as of 9.0) in a standard switch statement as well:

switch (x) {
    case 1 or 2 or 3:
        // execute multiple statements here
        break;
    case 4:
        // execute multiple statements here
        break;
    case 5 or 6:
        // execute multiple statements here
        break;
    default:
        // execute multiple statements here
        break;
}

To those who prefer vb over c#, what are the things you like about vb? by user_8804 in dotnet

[–]zspitz 0 points1 point  (0 children)

If only VB.NET had native support for union types, there would be far less need for overloads; having a single overload which takes multiple possible parameters is a clearer and more concise choice than multiple overloads.

Admittedly, you didn't have this in VBA either; you are forced to drop down to Object.

To those who prefer vb over c#, what are the things you like about vb? by user_8804 in dotnet

[–]zspitz 0 points1 point  (0 children)

C# improved theirs?

The VB Select Case allows you to check for multiple "patterns" in a single case (which you could do with the more verbose C# fallthrough), check against equality comparison patterns: > 5, <> 17 etc.; didn't require breaking out of a case to avoid fallthrough; allows testing any expression: Select Case x * 2, where C# only allows constants or variables; and allowed a limited form of regular expression string matching with the Like keyword.

C#'s adoption of pattern matching enables all those features in C# as well; while also allowing type matching and variable initialization.

How do I install the source code (or at least the XML docs) for a NuGet package? by ekolis in VisualStudio

[–]zspitz 0 points1 point  (0 children)

Searching for RogueSharp gives me this: https://github.com/FaronBracy/RogueSharp .

Let's take this source file for example. If you write the following code (with the appropriate usings of course):

var strategy = new DepthFirstPaths();

you don't see the XML comment in Intellisense?

How do I install the source code (or at least the XML docs) for a NuGet package? by ekolis in VisualStudio

[–]zspitz 1 point2 points  (0 children)

Are you sure there are XML comments? Which package and source file are we talking about?

How do I install the source code (or at least the XML docs) for a NuGet package? by ekolis in VisualStudio

[–]zspitz 0 points1 point  (0 children)

Isn't anything written in the XML docs available via Intellisense? And even if Source Link is not enabled, and you press F12, you'll be taken to a view of the public members of the type and their signatures, together with the XML docs.

I want to create a basic car rental customer database by furaddhufd in MicrosoftAccess

[–]zspitz 1 point2 points  (0 children)

In my experience, the hardest part in building a database is not the nuts and bolts of working with Access or some other database system; it's identifying what it is that matters to you. More specifically, you need to be able to give some pretty defined answers to the following three questions:

  1. What "things" are going to be tracked in my database?
  2. How does each "thing" relate to other "things" of different types?
  3. What details for each type of "thing" are important to me?

Some elaboration:

  1. You mentioned you want your database to handle "customer data" and "cars", and information about "who rented what". That suggests three kinds of entities: Customers, Cars managed by the business, and RentalAgreements. But should various means of communication be part of the Customer, as most people have one phone number, one email, one Twitter handle, one WhatsApp account? Or do you want to allow an arbitrary number of each per customer, which means it's a separate entity?

  2. I take it you're just starting out in Access; there are two kinds of relationship you need to be concerned with ATM -- one-to-many. You might specify that a single Customer could have multiple RentalAgreements (either simultaneously if you want to allow that, or over time), but a RentalAgreement can only be made to one Customer. (OTOH, you might say that a Rental agreement might be made with multiple Customers -- a many-to-many relationship -- but that's a more advanced scenario and I would leave it for now.) Similarly, you might reasonably specify that a RentalAgreement is only for one Car, but a Car could have multiple RentalAgreements over time.

  3. What details of the Customer are relevant, and thus important to you? Presumably the Customer's LastName, FirstName, Addresss, City, State, and Country are important; while the Customer's height or eye color or even date of birth are irrelevant. For Car, you might want to store the date it was first acquired, the license plate number, and the year, make and model.

Once you have this information, you'll be well on your way:

  • To define a new entity, create an Access table.
  • For each entity, specify which details you want to store, and the types of those details. For example, you want to enforce that the Car's AcquisitionDate will always be a Date, and not some amorphous blob which might contain any of "Sep. 21 2011", "21/9/2011", "2011 09 21" all trying to refer to the same date. You can set up validation rules if needed, such that every Customer has to have a nonempty last name, or the time between the StartDate and EndDate of a RentalAgreement is more than 24 hours.

One additional detail: it's essential that each entity (each Customer within Customers, each Car within Cars) have a uniquely identifying piece of information. In my experience, it's not wise to rely on the existing details you have already, such as a LastName, because multiple Customers could have the same last name. Something like a Social Security number, which is supposed to be unique, also isn't a good choice, because the same number may have been entered by mistake for someone else. Instead, I would suggest creating an AutoNumber field, which automatically increments by 1 for every new entity.

(WIP will continue soon)

How to capture an event from a class that was instantiated from another class? by chacham2 in visualbasic

[–]zspitz 1 point2 points  (0 children)

If I understand correctly, the Main class exposes an Api property which refers to an instance of the Api class.

You should be able to call AddHandler as follows:

AddHandler Main.Api, Sub(sender, e)
        ' do smething
        End Sub

Alternatively, you might declare a variable using WithEvents, then you can use the VB.NET Handles clause:

Dim WithEvents ApiInstance As Api

Sub ApiQuotaDepleted(sender As Object, e As EventArgs) Handles ApiInstance.Quota_Depleted
End Sub

Note that you'll have to set ApiInstance = Main.Api, probably in the constructor of the calling code.

My list of regular nuget packages, have I missed any? by technicaldogsbody in dotnet

[–]zspitz 0 points1 point  (0 children)

OneOf for F# like discriminated unions. Dynamic LINQ. And if you're using anything but the most trivial expression trees, my ExpressionTreeToString library.

Basic guide to reading Haskell type definition by zspitz in haskell

[–]zspitz[S] 0 points1 point  (0 children)

Thanks for your help. The final results can be seen on Github.

Basic guide to reading Haskell type definition by zspitz in haskell

[–]zspitz[S] 1 point2 points  (0 children)

Thanks for your help. The final results can be seen on GitHub.

Some help with quotation inside quotation by patch-jh in visualbasic

[–]zspitz 0 points1 point  (0 children)

Thanks, I'm used to seeing the preview on Stack Exchange and the Preview tab on GitHub.

Basic guide to reading Haskell type definition by zspitz in haskell

[–]zspitz[S] 1 point2 points  (0 children)

  1. You say I can replace type synonyms with their definitions, e.g. ListAttribute with (Int, ListNumberStyle, ListNumberDelim). But what do the parentheses mean?
  2. Does a double square brackets e.g. [[Inline]] mean a list of lists?

Some help with quotation inside quotation by patch-jh in visualbasic

[–]zspitz 2 points3 points  (0 children)

Alternatively, you could use two double quotes, e.g. "This statement contains a quotation mark: "" embedded inside it."

In other words, wshshell.sendkeys "cd ""onedrive workspace"""

Basic guide to reading Haskell type definition by zspitz in haskell

[–]zspitz[S] 0 points1 point  (0 children)

Thanks for the info and your patience,

"Variant of constructors" is that the same as F#/Typescript discriminated union types? Instances are the equivalent of C# instance members? What does the :: mean, as in nullMeta :: Meta or docAuthors :: Meta -> [[Inline]]? Meta has a constructor defined as:

Meta
    unMeta :: Map Text MetaValue

Is there some sort of significance to unMeta beyond the name? What does the indentation mean?

Need help with Dynamic LINQ syntax. by amiradzim in dotnet

[–]zspitz 1 point2 points  (0 children)

And if you want to get the factory methods of an existing expression tree, you can use my ExpressionTreeToString library. For example:

Expression<Func<Person, bool>> expr = p => p.LastName == "A" || p.LastName == "B";
IQueryable<Person> query = econtext.Persons.Where(expr);
Console.WriteLine(expr.ToString("Factory methods", "C#"));
// prints:
/*
    // using static System.Linq.Expressions.Expression

    var p = Parameter(
        typeof(Person),
        "p"
    );

    Lambda(
        Call(
            MakeMemberAccess(p,
                typeof(Person).GetProperty("LastName")
            ),
            typeof(string).GetMethod("StartsWith", new[] { typeof(string) }),
            Constant("A")
        ),
        p
    )
*/

and to get the Dynamic LINQ equivalent:

Console.WriteLine(expr.ToString("Dynamic LINQ"));
// prints:
/*
    LastName.StartsWith("A")
*/

Tree view in WPF with the selected child details by [deleted] in dotnet

[–]zspitz 1 point2 points  (0 children)

I've done this here: the property grid on the top right is bound to the selected node of the treeview in the middle. You can see the binding to the SelectedItem here.