Odata 를 Linq를 작성해서 바로 데이타를 볼수 있는 툴 좋다. ^^
In this article we will cover the simplest scenarios for connecting to LightSwitch using OData. We will not cover, inserting, updating, deleting, or validation.
The Application
We start with a simple LightSwitch application that contains a few Entities (tables) and Screens.
We Publish the application.
We enter some sample data.
Connecting To LightSwitch Using OData
We change the URL that we use to get to the application …
… to a URL with ApplicationData.svc.
This will allow us to see the OData Feed.
Using LinqPad
We can download and install LinqPad from: http://www.linqpad.net/.
We add a connection.
We select OData.
We enter the URL and click OK.
The Entities will show.
We can use the following query (in C# Statement(s) mode):
var DozenRedRoses =from Product in Products
where Product.ProductName == "Dozen Red Roses"
select Product;DozenRedRoses.Dump("The Dozen Red Roses");
// Set Product ID
var intProductID = DozenRedRoses.FirstOrDefault().Id;var OrderDetailsForRoses =from OrderDetail in OrderDetails
where OrderDetail.Product.Id == intProductIDwhere OrderDetail.Quantity > 1select OrderDetail;OrderDetailsForRoses.Dump("The order details for more than 2 roses");
// Get Order Detail IDs
List<int> OrderDetailIDs = new List<int>();foreach (var element in OrderDetailsForRoses){OrderDetailIDs.Add(element.OrderDetail_Order);}foreach (var element in OrderDetailIDs){var OrderForRoses =from Order in Orders
where Order.Id == elementselect Order;OrderForRoses.Dump("A order for more than 2 Red Roses");
}
To produce this result:
Security
We can enable Forms Authentication and deploy the application again.
When we try to navigate to the OData methods it prompts us for a valid account.
참조 :