コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public async Task <EmployeeClassification> GetByKeyAsync(int employeeClassificationKey)
 {
     return(await m_DataSource.GetByKey(TableName, employeeClassificationKey).ToObject <EmployeeClassification>().ExecuteAsync());
 }
コード例 #4
0
 public IEmployeeClassification?GetClassification(int employeeClassificationKey)
 {
     return(m_DataSource.GetByKey <EmployeeClassification>(employeeClassificationKey).ToObject().Execute());
 }
コード例 #5
0
 public ReadOnlyEmployeeClassification?GetByKey(int employeeClassificationKey)
 {
     return(m_DataSource.GetByKey <ReadOnlyEmployeeClassification>(employeeClassificationKey)
            .ToObjectOrNull <ReadOnlyEmployeeClassification>(RowOptions.InferConstructor).Execute());
 }
コード例 #6
0
 public EmployeeSimple?GetByKey(int employeeKey)
 {
     return(m_DataSource.GetByKey <EmployeeSimple>(employeeKey).ToObjectOrNull().Execute());
 }
コード例 #7
0
 public EmployeeClassification GetByKey(int employeeClassificationKey)
 {
     return(m_DataSource.GetByKey(TableName, employeeClassificationKey).ToObject <EmployeeClassification>().Execute());
 }
コード例 #8
0
 public Department?GetDepartmentIgnoringIsDeleted(int departmentKey)
 {
     return(m_DataSourceBypassSoftDelete.GetByKey <Department>(departmentKey).ToObjectOrNull().Execute());
 }
コード例 #9
0
 public Department?GetDepartment(int departmentKey)
 {
     return(m_DataSource.GetByKey <Department>(departmentKey).ToObjectOrNull().Execute());
 }
コード例 #10
0
 public Employee Get(int employeeKey)
 {
     return(m_DataSource.GetByKey(TableName, employeeKey).ToObject <Employee>().Execute());
 }
コード例 #11
0
 public Task <EmployeeClassification?> GetByKeyAsync(int employeeClassificationKey,
                                                     CancellationToken cancellationToken = default)
 {
     return(m_DataSource.GetByKey <EmployeeClassification>(employeeClassificationKey)
            .Compile().ToObjectOrNull().ExecuteAsync(cancellationToken));
 }