Entity SQL CREATEREF reference: http://msdn.microsoft.com/en-us/library/bb386880 (v = VS.90)
Used for "Creating object references in a set of objects." You can also find links to REF and DEREF at the link.
For VS 2010, this link: http://msdn.microsoft.com/en-us/library/bb386880 (v = VS.100)
Example from MSDN:
In the example below, Orders and BadOrders are both entities of type Order and Id are considered the only key property of Order. The example illustrates how we can create an object reference in BadOrders. Please note that the link may be hung. This link cannot actually identify a specific object. In these cases, the DEREF operation on this link returns zero.
select CreateRef(LOB.BadOrders, row(o.Id)) from LOB.Orders as o
Sample code for using the framework SQL entity:
using (EntityConnection conn = new EntityConnection("name=AdventureWorksEntities")) { conn.Open(); // Create a query that takes two parameters. string esqlQuery = @"SELECT VALUE Contact FROM AdventureWorksEntities.Contact AS Contact WHERE Contact.LastName = @ln AND Contact.FirstName = @fn"; try { using (EntityCommand cmd = new EntityCommand(esqlQuery, conn)) { // Create two parameters and add them to // the EntityCommand Parameters collection EntityParameter param1 = new EntityParameter(); param1.ParameterName = "ln"; param1.Value = "Adams"; EntityParameter param2 = new EntityParameter(); param2.ParameterName = "fn"; param2.Value = "Frances"; cmd.Parameters.Add(param1); cmd.Parameters.Add(param2); using (DbDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { // Iterate through the collection of Contact items. while (rdr.Read()) { Console.WriteLine(rdr["FirstName"]); Console.WriteLine(rdr["LastName"]); } } } } catch (EntityException ex) { Console.WriteLine(ex.ToString()); } conn.Close(); }
source share