コード例 #1
0
        public void CharByteArrayStringMappingTest()
        {
            File.WriteAllBytes("CharByteArrayData.zip", Properties.Resources.CharByteArrayDataZip);

            FastZip zip = new FastZip();

            zip.ExtractZip("CharByteArrayData.zip", this.TestContext.TestDeploymentDir, string.Empty);

            string connectionString = @"Provider=VFPOLEDB;Data Source=" + this.TestContext.TestDeploymentDir;

            using (var connection = new VfpConnection(connectionString)) {
                var provider = new VfpQueryProvider(connection, VfpLanguage.Default, new VfpImplicitMapping(), VfpQueryPolicy.Default);
                provider.AutoRightTrimStrings = true;
                provider.Log = Console.Out;
                var table = provider.GetTable <MenuList>("MenuList");

                var newItem = new MenuList {
                    Menu_Name = "blah", Alt_Name = "blahAlt", MenuActive = "N", MenuListId = 99
                };
                table.Insert(newItem);
                var existingItem = table.Where(x => x.MenuListId == newItem.MenuListId).OrderBy(x => x.MenuListId).Single();

                Assert.AreEqual(newItem.Alt_Name, existingItem.Alt_Name);
                Assert.AreEqual(newItem.Menu_Name, existingItem.Menu_Name);
                Assert.AreEqual(newItem.MenuActive, existingItem.MenuActive);
                Assert.AreEqual(newItem.MenuListId, existingItem.MenuListId);
            }
        }
コード例 #2
0
 public NorthwindDataContext(IRepository repository)
     : base(repository)
 {
     if (repository is DbEntityRepository)
     {
         this.Provider = ((DbEntityRepository)repository).Provider as VfpQueryProvider;
     }
 }
コード例 #3
0
        public void DecimalReadExceptionTest()
        {
            var connectionString = this.TestContext.TestDeploymentDir + @"\Decimal";

            using (VfpQueryProvider provider = VfpQueryProvider.Create(connectionString, null)) {
                var result = provider.GetTable <DecimalTable>("DecimalTable")
                             .OrderBy(x => x.nValue)
                             .Select(x => x.nValue)
                             .First();

                Assert.AreEqual(7654321.12345M, result);
            }
        }
コード例 #4
0
        private static DbEntityRepository CreateRepository(string connectionString)
        {
            VfpQueryProvider provider = VfpQueryProvider.Create(connectionString, null);

            Type type = typeof(NorthwindDataContext);

            // path of the xml file in the dll
            string xmlPath = Path.GetFileNameWithoutExtension(type.FullName) + ".Mapping.xml";

            using (StreamReader streamReader = new StreamReader(type.Assembly.GetManifestResourceStream(xmlPath))) {
                provider = provider.New(VfpXmlMapping.FromXml(streamReader.ReadToEnd()));
            }

            return(new DbEntityRepository(provider));
        }
コード例 #5
0
        public LinqToVfpDataContext(IRepository repository, TestContextWriter testContextWriter)
            : base(repository)
        {
            this.Provider = ((DbEntityRepository)repository).Provider as VfpQueryProvider;
            this.Provider.AutoRightTrimStrings = true;

            if (testContextWriter == null)
            {
                this.Provider.Log = new IQToolkitContrib.DebuggerWriter();
            }
            else
            {
                this.Provider.Log = testContextWriter;
            }
        }
コード例 #6
0
        public void CharByteArrayStringMappingTest()
        {
            File.WriteAllBytes("CharByteArrayData.zip", Properties.Resources.CharByteArrayDataZip);

            FastZip zip = new FastZip();
            zip.ExtractZip("CharByteArrayData.zip", this.TestContext.TestDeploymentDir, string.Empty);

            string connectionString = @"Provider=VFPOLEDB;Data Source=" + this.TestContext.TestDeploymentDir;
            using (var connection = new VfpConnection(connectionString)) {
                var provider = new VfpQueryProvider(connection, VfpLanguage.Default, new VfpImplicitMapping(), VfpQueryPolicy.Default);
                provider.AutoRightTrimStrings = true;
                provider.Log = Console.Out;
                var table = provider.GetTable<MenuList>("MenuList");

                var newItem = new MenuList { Menu_Name = "blah", Alt_Name = "blahAlt", MenuActive = "N", MenuListId = 99 };
                table.Insert(newItem);
                var existingItem = table.Where(x => x.MenuListId == newItem.MenuListId).OrderBy(x => x.MenuListId).Single();

                Assert.AreEqual(newItem.Alt_Name, existingItem.Alt_Name);
                Assert.AreEqual(newItem.Menu_Name, existingItem.Menu_Name);
                Assert.AreEqual(newItem.MenuActive, existingItem.MenuActive);
                Assert.AreEqual(newItem.MenuListId, existingItem.MenuListId);
            }
        }
コード例 #7
0
ファイル: NorthwindSession.cs プロジェクト: phaufe/LINQtoVFP
 public NorthwindSession(VfpQueryProvider provider)
     : base(provider)
 {
 }
コード例 #8
0
 public NorthwindContext(string connectionString, string mappingId)
     : base(VfpQueryProvider.Create(connectionString, mappingId))
 {
 }
コード例 #9
0
 public NorthwindDataContext(VfpQueryProvider provider)
 {
     this.Provider = provider;
 }
コード例 #10
0
 public NorthwindDataContext(VfpQueryProvider provider) : this(new DbEntityRepository(provider))
 {
 }
コード例 #11
0
 public NorthwindSession(VfpQueryProvider provider)
     : base(provider)
 {
 }
コード例 #12
0
        public DecimalDataContext(string connectionString)
        {
            var mappingId = typeof(DecimalDataContextAttributes).FullName;

            this.Provider = VfpQueryProvider.Create(connectionString, mappingId);
        }
コード例 #13
0
 public Context(string connectionString, string mappingId)
     : this(VfpQueryProvider.Create(connectionString, mappingId))
 {
 }
コード例 #14
0
 public Context(VfpQueryProvider provider)
     : base(provider)
 {
 }