public void Example1_Chain() { var guid = Guid.NewGuid(); var dog = s_DataSource.Sql("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid }).ToCollection <Dog>().Execute();; Assert.AreEqual(1, dog.Count()); Assert.IsNull(dog.First().Age); Assert.AreEqual(guid, dog.First().Id); //Or if you just want one: var aDog = s_DataSource.Sql("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid }).ToObject <Dog>().Execute();; Assert.IsNull(aDog.Age); Assert.AreEqual(guid, aDog.Id); //Make it more realistic by actually inserting a record var originalDog = new Dog() { Age = 2, Name = "Fido", Weight = 2.5f }; var key = s_DataSource.Insert("Dog", originalDog).ToGuid().Execute(); //And then re-read it back var fetchedDog = s_DataSource.GetByKey("Dog", key).ToObject <Dog>().Execute(); Assert.AreEqual(originalDog.Age, fetchedDog.Age); Assert.AreEqual(originalDog.Name, fetchedDog.Name); Assert.AreEqual(originalDog.Weight, fetchedDog.Weight); }
public ProductLine?GetByKey(int productLineKey, bool includeProducts) { var result = m_DataSource.GetByKey <ProductLine>(productLineKey).ToObjectOrNull().Execute(); if (result != null && includeProducts) { var children = m_DataSource.From <Product>(new { result.ProductLineKey }).ToCollection().Execute(); result.Products.AddRange(children); } return(result); }
public async Task <EmployeeClassification> GetByKeyAsync(int employeeClassificationKey) { return(await m_DataSource.GetByKey(TableName, employeeClassificationKey).ToObject <EmployeeClassification>().ExecuteAsync()); }
public IEmployeeClassification?GetClassification(int employeeClassificationKey) { return(m_DataSource.GetByKey <EmployeeClassification>(employeeClassificationKey).ToObject().Execute()); }
public ReadOnlyEmployeeClassification?GetByKey(int employeeClassificationKey) { return(m_DataSource.GetByKey <ReadOnlyEmployeeClassification>(employeeClassificationKey) .ToObjectOrNull <ReadOnlyEmployeeClassification>(RowOptions.InferConstructor).Execute()); }
public EmployeeSimple?GetByKey(int employeeKey) { return(m_DataSource.GetByKey <EmployeeSimple>(employeeKey).ToObjectOrNull().Execute()); }
public EmployeeClassification GetByKey(int employeeClassificationKey) { return(m_DataSource.GetByKey(TableName, employeeClassificationKey).ToObject <EmployeeClassification>().Execute()); }
public Department?GetDepartmentIgnoringIsDeleted(int departmentKey) { return(m_DataSourceBypassSoftDelete.GetByKey <Department>(departmentKey).ToObjectOrNull().Execute()); }
public Department?GetDepartment(int departmentKey) { return(m_DataSource.GetByKey <Department>(departmentKey).ToObjectOrNull().Execute()); }
public Employee Get(int employeeKey) { return(m_DataSource.GetByKey(TableName, employeeKey).ToObject <Employee>().Execute()); }
public Task <EmployeeClassification?> GetByKeyAsync(int employeeClassificationKey, CancellationToken cancellationToken = default) { return(m_DataSource.GetByKey <EmployeeClassification>(employeeClassificationKey) .Compile().ToObjectOrNull().ExecuteAsync(cancellationToken)); }