├── .gitignore
├── README.md
├── docs
├── NI.Data.Storage.shfbproj
├── NI.Data.shfbproj
├── NI.Ioc.shfbproj
└── NI.Vfs.shfbproj
├── examples
├── NI.Data.Examples.WebForms
│ ├── App_Code
│ │ └── DataHelper.cs
│ ├── NI.Data.Examples.WebForms.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Web.config
│ ├── book.aspx
│ └── default.aspx
├── NI.Examples.sln
└── NI.Ioc.Examples.ConsoleApp
│ ├── App.config
│ ├── NI.Ioc.Examples.ConsoleApp.csproj
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── TestClass.cs
└── src
├── NI.Data.MySql
├── MySqlDalcFactory.cs
├── NI.Data.MySql.csproj
├── NI.Data.MySql.nuspec
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── NI.Data.SQLite
├── NI.Data.SQLite.csproj
├── NI.Data.SQLite.nuspec
├── Properties
│ └── AssemblyInfo.cs
├── SQLiteDalcFactory.cs
└── packages.config
├── NI.Data.Storage.Tests
├── DataSetStorageContext.cs
├── DataSetStorageDalcTests.cs
├── Model
│ ├── DataSchemaTests.cs
│ └── RelationshipTests.cs
├── NI.Data.Storage.Tests.csproj
├── ObjectContainerDalcStorageTest.cs
├── ObjectContainerSqlDalcStorageTests.cs
├── OwlEmbeddedSchemaStorageTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── RestServiceTest.cs
├── SQLiteStorageContext.cs
├── SQLiteStorageDalcTests.cs
└── packages.config
├── NI.Data.Storage
├── DalcStorageQueryTranslator.cs
├── FieldMapping.cs
├── Interfaces
│ ├── IDataSchemaStorage.cs
│ ├── IObjectContainerStorage.cs
│ └── ISqlObjectContainerStorage.cs
├── MetadataTableSchemaStorage.cs
├── Model
│ ├── Class.cs
│ ├── ClassPropertyLocation.cs
│ ├── DataSchema.cs
│ ├── ObjectContainer.cs
│ ├── ObjectRelation.cs
│ ├── Property.cs
│ ├── PropertyDataType.cs
│ └── Relationship.cs
├── NI.Data.Storage.csproj
├── NI.Data.Storage.nuspec
├── ObjectContainerDalcStorage.cs
├── ObjectContainerSqlDalcStorage.cs
├── OwlEmbeddedSchemaStorage.cs
├── Properties
│ └── AssemblyInfo.cs
├── SchemaDataSetFactory.cs
├── Service
│ ├── Actions
│ │ ├── ChangeRow.cs
│ │ ├── GetDataSchema.cs
│ │ └── LoadRelex.cs
│ ├── ApiException.cs
│ ├── BasicAuthorizationManager.cs
│ ├── ErrorHandler.cs
│ ├── IStorageService.cs
│ ├── Schema
│ │ ├── DataRowItem.cs
│ │ ├── DictionaryItem.cs
│ │ ├── GetDataSchemaResult.cs
│ │ ├── LoadRowsResult.cs
│ │ └── LoadValuesResult.cs
│ └── StorageService.cs
└── StorageDalc.cs
├── NI.Data.Vfs
├── DalcFileContent.cs
├── DalcFileObject.cs
├── DalcFileStream.cs
├── DalcFileSystem.cs
├── DalcFileSystemHelper.cs
├── DataRowDictionary.cs
├── FileSystemDalc.cs
├── NI.Data.Vfs.csproj
└── Properties
│ └── AssemblyInfo.cs
├── NI.Data
├── AssemblyInfo.cs
├── DalcExt.cs
├── DataEventBroker.cs
├── DataHelper.cs
├── DataRowDalcMapper.cs
├── DataRowTrigger.cs
├── DataSetFactory.cs
├── DatasetDalc.cs
├── DbCommandEventArgs.cs
├── DbCommandGenerator.cs
├── DbDALC.cs
├── DbDalcView.cs
├── DbSqlBuilder.cs
├── DbTypeResolver.cs
├── DbValueComparer.cs
├── EvalQueryCondition.cs
├── GenericDbProviderFactory.cs
├── Interfaces
│ ├── IDalc.cs
│ ├── IDataSetFactory.cs
│ ├── IDbCommandGenerator.cs
│ ├── IDbDalcView.cs
│ ├── IDbProviderFactory.cs
│ ├── IDbSqlBuilder.cs
│ ├── IObjectDataRowMapper.cs
│ ├── IQueryValue.cs
│ ├── ISqlBuilder.cs
│ └── ISqlDalc.cs
├── Linq
│ ├── DalcData.cs
│ ├── DalcLinqExtensions.cs
│ ├── DalcRecord.cs
│ └── QueryProvider.cs
├── Logger.cs
├── NI.Data.csproj
├── NI.Data.nuspec
├── ObjectDalcMapper.cs
├── Permissions
│ ├── DbPermissionCommandGenerator.cs
│ ├── IQueryRule.cs
│ ├── PermissionContext.cs
│ └── QueryRule.cs
├── PropertyDataRowMapper.cs
├── Query
│ ├── QConst.cs
│ ├── QField.cs
│ ├── QRawSql.cs
│ ├── QSort.cs
│ ├── QTable.cs
│ ├── QVar.cs
│ ├── Query.cs
│ ├── QueryConditionNode.cs
│ ├── QueryGroupNode.cs
│ ├── QueryNegationNode.cs
│ ├── QueryNode.cs
│ └── QueryRawSqlNode.cs
├── RelationalExpressions
│ ├── RelExParser.cs
│ └── RelexBuilder.cs
├── SimpleStringTemplate.cs
├── SqlBuilder.cs
├── SqlClient
│ ├── SqlClientDalcFactory.cs
│ └── SqlClientDbSqlBuilder.cs
├── SqlCommandTraceTrigger.cs
├── Triggers
│ ├── DataRowActionType.cs
│ ├── DataRowTrigger.cs
│ ├── InvalidateDataDependencyTrigger.cs
│ └── SqlCommandTraceTrigger.cs
└── Web
│ ├── DalcDataSource.cs
│ ├── DalcDataSourceChangeEventArgs.cs
│ ├── DalcDataSourceSelectEventArgs.cs
│ ├── DalcDataSourceView.cs
│ └── DataCacheDependency.cs
├── NI.Ioc
├── ApplicationContainer.cs
├── ArrayFactory.cs
├── AssemblyInfo.cs
├── BaseMethodInvokingFactory.cs
├── ComponentConfiguration.xsd
├── ComponentFactory.cs
├── ComponentFactoryContext.cs
├── ComponentFactoryExt.cs
├── ComponentFactoryInvokingFactory.cs
├── ConstDictionary.cs
├── DelegateFactory.cs
├── DependencyAttribute.cs
├── EventBinder.cs
├── Exceptions
│ └── XmlConfigurationException.cs
├── IndexerInvokingFactory.cs
├── IndexerProxy.cs
├── Interfaces
│ ├── IComponentFactory.cs
│ ├── IComponentFactoryAware.cs
│ ├── IComponentFactoryConfiguration.cs
│ ├── IComponentInitInfo.cs
│ ├── IFactoryComponent.cs
│ ├── IMapEntryInfo.cs
│ ├── IPropertyInitInfo.cs
│ ├── IServiceProviderAware.cs
│ ├── IValueFactory.cs
│ └── IValueInitInfo.cs
├── MethodInvokingFactory.cs
├── NI.Ioc.csproj
├── NI.Ioc.nuspec
├── PropertyInvokingFactory.cs
├── ReplacingFactory.cs
├── Schema
│ ├── ComponentConfiguration.cs
│ ├── ComponentInitInfo.cs
│ ├── ListValueInitInfo.cs
│ ├── MapEntryInfo.cs
│ ├── MapValueInitInfo.cs
│ ├── PropertyInitInfo.cs
│ ├── RefValueInitInfo.cs
│ ├── TypeValueInitInfo.cs
│ └── ValueInitInfo.cs
├── ServiceProviderContext.cs
├── StaticFieldInvokingFactory.cs
├── StaticMethodInvokingFactory.cs
├── StaticPropertyInvokingFactory.cs
├── Summary.xml
├── TypeResolver.cs
├── XmlComponentConfiguration.cs
├── XmlComponentConfigurationSectionHandler.cs
├── XmlServiceProvider.cs
└── XmlServiceProvider.resx
├── NI.Tests
├── Data
│ ├── DataEventBrokerTest.cs
│ ├── DataSetDalcTest.cs
│ ├── DbCommandGeneratorTest.cs
│ ├── LinqTests.cs
│ ├── PermissionTest.cs
│ ├── QueryTest.cs
│ ├── SQLiteDalcTest.cs
│ └── SimpleStringTemplateTest.cs
├── Ioc
│ ├── ArrayFactoryTest.cs
│ ├── ComponentFactoryTest.cs
│ ├── EventBinderTest.cs
│ ├── FuncInterfaceTest.cs
│ ├── MethodInvokingFactoryTest.cs
│ ├── StaticMethodInvokingFactoryTest.cs
│ ├── StaticPropertyInvokingFactoryTest.cs
│ └── XmlComponentConfigurationTest.cs
├── NI.Tests.csproj
├── Properties
│ └── AssemblyInfo.cs
├── RelationalExpressions
│ └── RelExQueryParserTest.cs
├── Text
│ └── EvalTest.cs
├── Vfs
│ └── VfsTest.cs
└── packages.config
├── NI.Text
├── AssemblyInfo.cs
├── DataBind.cs
├── EvalHelper.cs
├── IndexerProxy.cs
├── NI.Text.csproj
├── NI.Text.nuspec
├── StringTemplate.cs
└── Summary.xml
├── NI.Vfs
├── AllFileSelector.cs
├── AssemblyInfo.cs
├── Exceptions
│ └── FileSystemException.cs
├── ExtensionFileSelector.cs
├── FileObjectComparer.cs
├── FileObjectEventArgs.cs
├── FileObjectExt.cs
├── Interfaces
│ ├── IFileContent.cs
│ ├── IFileObject.cs
│ ├── IFileSelector.cs
│ └── IFileSystem.cs
├── ListFileSelector.cs
├── LocalFile.cs
├── LocalFileContent.cs
├── LocalFilesystem.cs
├── MaskFileSelector.cs
├── MemoryFile.cs
├── MemoryFileContent.cs
├── MemoryFileSystem.cs
├── NI.Vfs.csproj
├── NI.Vfs.nuspec
├── RegexFileSelector.cs
└── VfsXmlResolver.cs
└── NICNET.sln
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | .idea/
3 | /examples/*/bin
4 | /examples/*/obj
5 | /examples/*.suo
6 | /examples/*/*.user
7 | bin
8 | obj
9 | /src/*/NI.*.xml
10 | /src/*/*.user
11 | /src/*.suo
12 | /src/packages
13 | /src/NI.Tests/x64
14 | /src/NI.Tests/x86
15 | /src/NI.Data.Storage.Tests/x64
16 | /src/NI.Data.Storage.Tests/x86
17 | /src/NI.Data.SQLite/x64
18 | /src/NI.Data.SQLite/x86
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NIC.NET
2 | NIC.NET is a set of open source reusable components originally developed by NewtonIdeas.com company in 2005-2008.
3 | Right now these components are maintained by NReco team as part of NReco Framework infrastructure.
4 |
5 | Core components:
6 |
12 | These components are also available as nuget packages.
13 |
14 | ## Copyright & License
15 | NIC.NET Version 1.0 © 2005-2008 NewtonIdeas.com (published under LGPL)
16 | Changes and version 2.0 © 2008-2015 Vitalii Fedorchenko + other contributors (LGPL)
17 |
--------------------------------------------------------------------------------
/examples/NI.Data.Examples.WebForms/App_Code/DataHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Data;
5 | using System.Web;
6 |
7 | namespace NI.Data.Examples.WebForms.App_Code {
8 |
9 | public static class DataHelper {
10 |
11 | public static IDalc GetDalc() {
12 | DataSet ds = HttpContext.Current.Session["dataset"] as DataSet;
13 | if (ds == null) {
14 | ds = CreateBookDS();
15 | var r = ds.Tables["books"].NewRow();
16 | r["title"] = "Twenty Thousand Leagues Under the Sea";
17 | r["description"] = "Twenty Thousand Leagues Under the Sea is a classic science fiction novel by French writer Jules Verne published in 1870. It tells the story of Captain Nemo and his submarine Nautilus, as seen from the perspective of Professor Pierre Aronnax.";
18 | r["rating"] = 5;
19 | r["author_id"] = 1;
20 | ds.Tables["books"].Rows.Add(r);
21 |
22 | var author1Row = ds.Tables["authors"].NewRow();
23 | author1Row["name"] = "Jules Verne";
24 | ds.Tables["authors"].Rows.Add(author1Row);
25 |
26 | ds.AcceptChanges();
27 | HttpContext.Current.Session["dataset"] = ds;
28 | }
29 | return new DataSetDalc(ds);
30 | }
31 |
32 | public static DataSet CreateBookDS() {
33 | var ds = new DataSet();
34 | var bookTbl = ds.Tables.Add("books");
35 | var idCol = bookTbl.Columns.Add("id", typeof(int));
36 | idCol.AutoIncrement = true;
37 | idCol.AutoIncrementSeed = 1;
38 | bookTbl.PrimaryKey = new[] { idCol };
39 |
40 | bookTbl.Columns.Add("title", typeof(string));
41 | bookTbl.Columns.Add("description", typeof(string));
42 | bookTbl.Columns.Add("author_id", typeof(int));
43 | bookTbl.Columns.Add("rating", typeof(int));
44 |
45 | var authorTbl = ds.Tables.Add("authors");
46 | var authorIdCol = authorTbl.Columns.Add("id", typeof(int));
47 | authorIdCol.AutoIncrement = true;
48 | authorIdCol.AutoIncrementSeed = 1;
49 | authorTbl.PrimaryKey = new[] { authorIdCol };
50 | authorTbl.Columns.Add("name", typeof(string));
51 |
52 | return ds;
53 | }
54 |
55 | }
56 | }
--------------------------------------------------------------------------------
/examples/NI.Data.Examples.WebForms/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NI.Data.Examples.WebForms")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vitalii Fedorchenko")]
12 | [assembly: AssemblyProduct("NI.Data.Examples.WebForms")]
13 | [assembly: AssemblyCopyright("Copyright © Vitalii Fedorchenko 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8336a2cb-fbe5-4d1c-a49a-4d981dc8f647")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/examples/NI.Data.Examples.WebForms/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/NI.Examples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Express 2013 for Web
4 | VisualStudioVersion = 12.0.30501.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NI.Ioc.Examples.ConsoleApp", "NI.Ioc.Examples.ConsoleApp\NI.Ioc.Examples.ConsoleApp.csproj", "{61A57744-B9A6-41C2-8215-A2452BE90403}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NI.Data.Examples.WebForms", "NI.Data.Examples.WebForms\NI.Data.Examples.WebForms.csproj", "{075ECF83-8A22-44CE-ACB5-A0AB3FB3FF41}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NI.Data", "..\src\NI.Data\NI.Data.csproj", "{AC4B7A7E-55CA-4EAE-9FFA-DD6582390E81}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NI.Ioc", "..\src\NI.Ioc\NI.Ioc.csproj", "{25702474-5D4D-4EEA-A68A-3662A0966ED6}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {61A57744-B9A6-41C2-8215-A2452BE90403}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {61A57744-B9A6-41C2-8215-A2452BE90403}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {61A57744-B9A6-41C2-8215-A2452BE90403}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {61A57744-B9A6-41C2-8215-A2452BE90403}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {075ECF83-8A22-44CE-ACB5-A0AB3FB3FF41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {075ECF83-8A22-44CE-ACB5-A0AB3FB3FF41}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {075ECF83-8A22-44CE-ACB5-A0AB3FB3FF41}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {075ECF83-8A22-44CE-ACB5-A0AB3FB3FF41}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {AC4B7A7E-55CA-4EAE-9FFA-DD6582390E81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {AC4B7A7E-55CA-4EAE-9FFA-DD6582390E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {AC4B7A7E-55CA-4EAE-9FFA-DD6582390E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {AC4B7A7E-55CA-4EAE-9FFA-DD6582390E81}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {25702474-5D4D-4EEA-A68A-3662A0966ED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {25702474-5D4D-4EEA-A68A-3662A0966ED6}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {25702474-5D4D-4EEA-A68A-3662A0966ED6}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {25702474-5D4D-4EEA-A68A-3662A0966ED6}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | EndGlobal
41 |
--------------------------------------------------------------------------------
/examples/NI.Ioc.Examples.ConsoleApp/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Configuration;
6 |
7 | using NI.Ioc;
8 |
9 | namespace NI.Ioc.Examples.ConsoleApp
10 | {
11 | class Program
12 | {
13 | static void Main(string[] args)
14 | {
15 | Console.WriteLine("Loading IoC-container configuration...");
16 |
17 | var config = ConfigurationManager.GetSection("appContainer") as IComponentFactoryConfiguration;
18 | // or variant that is marked as not deprecated
19 |
20 | Console.WriteLine("Creating IoC-container...");
21 | var factory = new ComponentFactory(config, true);
22 |
23 | Console.WriteLine("Created {0} non-lazy instances", factory.Counters.CreateInstance);
24 |
25 | var componentNames = new[] {"datetimenow", "datetimenow-3days", "nonLazyNonSingletonTestComponent", "appName"};
26 |
27 | foreach (var componentName in componentNames) {
28 | Console.WriteLine("'{0}'.ToString(): {1}", componentName, factory.GetComponent(componentName));
29 | }
30 |
31 | Console.ReadLine();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/NI.Ioc.Examples.ConsoleApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NI.Ioc.Examples.ConsoleApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("NI")]
12 | [assembly: AssemblyProduct("NI.Ioc.Examples.ConsoleApp")]
13 | [assembly: AssemblyCopyright("Copyright © NI 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("18f9b9b8-450a-40b6-8899-8b17ca7c80b0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/NI.Data.MySql/MySqlDalcFactory.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2004-2012 NewtonIdeas
5 | * Distributed under the LGPL licence
6 | *
7 | * Unless required by applicable law or agreed to in writing, software
8 | * distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | #endregion
14 |
15 | using System;
16 | using System.Data;
17 | using System.Data.Common;
18 | using MySql.Data.MySqlClient;
19 | using MySql.Data;
20 | using System.ComponentModel;
21 |
22 | namespace NI.Data.MySql
23 | {
24 |
25 | ///
26 | /// MySQL Dalc Factory implementation
27 | ///
28 | public class MySqlDalcFactory : GenericDbProviderFactory
29 | {
30 |
31 | public MySqlDalcFactory()
32 | : base(MySqlClientFactory.Instance) {
33 | }
34 |
35 | public override object GetInsertId(IDbConnection connection) {
36 | if (connection.State != ConnectionState.Open)
37 | throw new InvalidOperationException("GetInsertId requires opened connection");
38 | using (var cmd = CreateCommand()) {
39 | cmd.CommandText = "SELECT LAST_INSERT_ID()";
40 | cmd.Connection = connection;
41 | return cmd.ExecuteScalar();
42 | }
43 | }
44 |
45 |
46 |
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/NI.Data.MySql/NI.Data.MySql.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | $title$
7 | $author$
8 | $author$
9 |
10 | http://www.nrecosite.com
11 |
12 | false
13 | $description$
14 | Copyright 2004-2014 Newtonideas
15 | NI.Data MySql
16 |
17 |
--------------------------------------------------------------------------------
/src/NI.Data.MySql/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NI.Data.MySql")]
9 | [assembly: AssemblyDescription("MySql Data Provider factory for DALC")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("NewtonIdeas")]
12 | [assembly: AssemblyProduct("Open NIC.NET")]
13 | [assembly: AssemblyCopyright("Copyright © NewtonIdeas 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ba099873-41cb-4a34-9643-255c3982c41b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.0.1")]
36 | [assembly: AssemblyFileVersion("2.0.1")]
37 |
--------------------------------------------------------------------------------
/src/NI.Data.MySql/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/NI.Data.SQLite/NI.Data.SQLite.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | $title$
7 | $author$
8 | $author$
9 |
10 | http://www.nrecosite.com/dalc_net.aspx
11 |
12 | false
13 | $description$
14 | Copyright 2004-2014 Newtonideas
15 | NI.Data SQLite
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/NI.Data.SQLite/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NI.Data.SQLite")]
9 | [assembly: AssemblyDescription("SQLite Data Provider factory for NI.Data DALC")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("NewtonIdeas")]
12 | [assembly: AssemblyProduct("Open NIC.NET")]
13 | [assembly: AssemblyCopyright("Copyright © 2013 NewtonIdeas")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ea45aedd-e010-421f-bc03-52e7c2075cd6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.0.0")]
36 | [assembly: AssemblyFileVersion("2.0.0")]
37 |
--------------------------------------------------------------------------------
/src/NI.Data.SQLite/SQLiteDalcFactory.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2004-2013 NewtonIdeas
5 | * Distributed under the LGPL licence
6 | *
7 | * Unless required by applicable law or agreed to in writing, software
8 | * distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | #endregion
14 |
15 | using System;
16 | using System.Data;
17 | using System.Data.Common;
18 | using System.Data.SQLite;
19 | using System.ComponentModel;
20 |
21 | namespace NI.Data.SQLite
22 | {
23 |
24 | ///
25 | /// SQLite Dalc Factory implementation
26 | ///
27 | public class SQLiteDalcFactory : GenericDbProviderFactory
28 | {
29 | public SQLiteDalcFactory()
30 | : base(SQLiteFactory.Instance) {
31 | ParamPlaceholderFormat = "?";
32 |
33 | }
34 |
35 | public override object GetInsertId(IDbConnection connection) {
36 | if (connection.State != ConnectionState.Open)
37 | throw new InvalidOperationException("GetInsertId requires opened connection");
38 | return ((SQLiteConnection)connection).LastInsertRowId;
39 | }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/NI.Data.SQLite/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage.Tests/Model/DataSchemaTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using NUnit.Framework;
8 |
9 | using NI.Data.Storage.Model;
10 |
11 | namespace NI.Data.Storage.Tests.Model {
12 |
13 | [TestFixture]
14 | public class DataSchemaTests {
15 |
16 | [Test]
17 | public void InferRelationshipByID() {
18 | var schema = DataSetStorageContext.CreateTestSchema();
19 |
20 | var r1 = schema.InferRelationshipByID("contacts_contactCompany_companies.companies_companyCountry_countries", schema.FindClassByID("contacts") );
21 | Assert.NotNull(r1);
22 | Assert.True(r1.Inferred);
23 | Assert.AreEqual(2, r1.InferredByRelationships.Count() );
24 | Assert.AreEqual("countries", r1.Object.ID );
25 |
26 | var r2 = schema.InferRelationshipByID("companies_companyCountry_countries.contacts_contactCompany_companies", schema.FindClassByID("countries"));
27 | Assert.NotNull(r2);
28 | Assert.True(r2.Inferred);
29 | Assert.AreEqual("contacts", r2.Object.ID);
30 | }
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage.Tests/Model/RelationshipTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using NUnit.Framework;
8 |
9 | using NI.Data.Storage.Model;
10 |
11 | namespace NI.Data.Storage.Tests.Model {
12 |
13 | [TestFixture]
14 | public class RelationshipTests {
15 |
16 | [Test]
17 | public void EqualsAndHashCode() {
18 | var class1 = new Class("class1");
19 | var class2 = new Class("class2");
20 | var pred1 = new Class("pred1") { IsPredicate = true };
21 | var pred2 = new Class("pred2") { IsPredicate = true };
22 |
23 | var rel1 = new Relationship(class1, pred1, class2, false,false, null);
24 | var rel1same = new Relationship(class1, pred1, class2, false,false, null);
25 | Assert.AreEqual(
26 | rel1same, rel1);
27 | Assert.AreEqual(
28 | rel1same.GetHashCode(), rel1.GetHashCode() );
29 | Assert.AreNotEqual(
30 | new Relationship(class2, pred1, class1, false, false, null), rel1);
31 | Assert.AreNotEqual(
32 | new Relationship(class1, pred2, class2, false, false, null), rel1);
33 |
34 | var rel2 = new Relationship(class2, pred2, class1, false, false, null);
35 | var infRel1 = new Relationship(class1, new[] { rel1, rel2 }, class1);
36 | var infRel1same = new Relationship(class1, new[] { rel1, rel2 }, class1);
37 | Assert.True(infRel1.Inferred);
38 | Assert.AreEqual( infRel1same, infRel1 );
39 | Assert.AreEqual(infRel1same.GetHashCode(), infRel1.GetHashCode() );
40 |
41 | }
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NI.Data.Storage.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("NI.Data.Storage.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("19c2ee8a-3e50-425d-ab48-49e156d5694b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/FieldMapping.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace NI.Data.Storage {
7 | public class FieldMapping {
8 | QField[] Fields;
9 | QField[] CompactFields;
10 | IDictionary DirectMapping;
11 | IDictionary RevMapping;
12 | public FieldMapping(QField[] fields) {
13 | Fields = fields;
14 | DirectMapping = new Dictionary();
15 | RevMapping = new Dictionary();
16 | if (fields != null && fields.Length > 0) {
17 | CompactFields = new QField[Fields.Length];
18 | for (int i = 0; i < CompactFields.Length; i++) {
19 | var f = Fields[i];
20 | if (f.Prefix != null && f.Expression == null) {
21 | var originalFieldName = f.ToString().Replace('.', '_');
22 | var compactName = "f_" + i.ToString() + "_" + f.Name;
23 | RevMapping[compactName] = originalFieldName;
24 | DirectMapping[originalFieldName] = compactName;
25 | CompactFields[i] = new QField(compactName, f.ToString());
26 | } else {
27 | CompactFields[i] = f;
28 | }
29 | }
30 | } else {
31 | CompactFields = Fields;
32 | }
33 | }
34 |
35 | public QField[] GetCompactFields() {
36 | return CompactFields;
37 | }
38 |
39 | public string GetOriginalFieldName(string compactName) {
40 | return RevMapping.ContainsKey(compactName) ? RevMapping[compactName] : compactName;
41 | }
42 |
43 | public string GetCompactFieldName(string originalName) {
44 | return DirectMapping.ContainsKey(originalName) ? DirectMapping[originalName] : originalName;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Interfaces/IDataSchemaStorage.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Threading.Tasks;
21 |
22 | using NI.Data.Storage.Model;
23 |
24 | namespace NI.Data.Storage {
25 |
26 | ///
27 | /// Represents data schema persistence storage
28 | ///
29 | public interface IDataSchemaStorage {
30 |
31 | ///
32 | /// Returns actual from metadata storage
33 | ///
34 | DataSchema GetSchema();
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Interfaces/ISqlObjectContainerStorage.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Threading.Tasks;
21 | using System.Data;
22 |
23 | using NI.Data;
24 | using NI.Data.Storage.Model;
25 |
26 | namespace NI.Data.Storage {
27 |
28 | ///
29 | /// Represents abstract SQL-specific storage for
30 | ///
31 | public interface ISqlObjectContainerStorage : IObjectContainerStorage {
32 |
33 | ///
34 | /// Execute object query and pass result as for specified handler
35 | ///
36 | /// object query to execute
37 | /// delegate that accepts with query result
38 | void LoadObjectReader(Query q, Action handler);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Model/ObjectRelation.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Threading.Tasks;
21 |
22 | namespace NI.Data.Storage.Model {
23 |
24 | ///
25 | /// Represents relation between two objects
26 | ///
27 | public class ObjectRelation {
28 |
29 | public long SubjectID { get; private set; }
30 | public Relationship Relation { get; private set; }
31 | public long ObjectID { get; private set; }
32 |
33 | public ObjectRelation(long subjId, Relationship r, long objId) {
34 | SubjectID = subjId;
35 | Relation = r;
36 | ObjectID = objId;
37 | }
38 |
39 | public override string ToString() {
40 | return String.Format("[SubjectID={0}; {1}; ObjectID={2}]", SubjectID, Relation.ToString(), ObjectID);
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/NI.Data.Storage.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | $title$
7 | Vitalii Fedorchenko
8 | $author$
9 |
10 | http://www.nrecosite.com/semantic_storage_net.aspx
11 |
12 | false
13 | $description$
14 | Copyright 2013-2015 Vitalii Fedorchenko
15 | NI.Data ADO.NET DAL EAV Engine Entity-Attribute-Value Triplestore
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NI.Data.Storage")]
9 | [assembly: AssemblyDescription("NI.Data.Storage provides ADO.NET-like access to data represented with entity-attribute-value model. Entities may be queried, created, updated and deleted like usual database tables.")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Vitalii Fedorchenko")]
12 | [assembly: AssemblyProduct("NI.Data.Storage")]
13 | [assembly: AssemblyCopyright("Copyright © Vitalii Fedorchenko 2013-2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("fd64292d-46ac-4c2c-81d0-932893b2f02f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.1.0.0")]
36 | [assembly: AssemblyFileVersion("2.1.0.0")]
37 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/SchemaDataSetFactory.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2014 Vitalii Fedorchenko
5 | * Distributed under the LGPL licence
6 | *
7 | * Unless required by applicable law or agreed to in writing, software
8 | * distributed under the License is distributed on an "AS IS" BASIS,
9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | * See the License for the specific language governing permissions and
11 | * limitations under the License.
12 | */
13 | #endregion
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Linq;
18 | using System.Text;
19 | using System.Data;
20 |
21 | using NI.Data;
22 | using NI.Data.Storage.Model;
23 |
24 | namespace NI.Data.Storage {
25 |
26 | ///
27 | /// implementation based on .
28 | ///
29 | public class SchemaDataSetFactory : IDataSetFactory {
30 |
31 | protected Func GetSchema { get; set; }
32 |
33 | ///
34 | /// Initializes new instance of SchemaDataSetFactory with specified DataSchema provider.
35 | ///
36 | /// delegate that returns DataSchema structure
37 | public SchemaDataSetFactory(Func getSchema) {
38 | GetSchema = getSchema;
39 | }
40 |
41 | ///
42 | /// Construct DataSet object with DataTable schema for specifed table name.
43 | ///
44 | /// table name
45 | /// DataSet with DataTable for specified table name
46 | public DataSet GetDataSet(string tableName) {
47 | if (String.IsNullOrEmpty(tableName))
48 | throw new ArgumentNullException("tableName is empty");
49 | var schema = GetSchema();
50 | var ds = new DataSet();
51 | var dataClass = schema.FindClassByID(tableName);
52 | if (dataClass==null)
53 | return null;
54 |
55 | var tbl = dataClass.CreateDataTable();
56 | ds.Tables.Add(tbl);
57 | return ds;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/Actions/GetDataSchema.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Runtime.Serialization;
21 | using System.ServiceModel;
22 |
23 | using NI.Data.Storage.Model;
24 | using NI.Data.Storage.Service.Schema;
25 |
26 | namespace NI.Data.Storage.Service.Actions {
27 |
28 | public class GetDataSchema {
29 |
30 | DataSchema Schema;
31 |
32 | public GetDataSchema(DataSchema schema) {
33 | Schema = schema;
34 | }
35 |
36 | public GetDataSchemaResult Execute() {
37 | var res = new GetDataSchemaResult();
38 |
39 | foreach (var c in Schema.Classes.Where(c=>!c.IsPredicate) ) {
40 | var cInfo = new DataSchemaClassInfo() {
41 | ID = c.ID,
42 | Name = c.Name,
43 | };
44 | foreach (var cProp in c.Properties) {
45 | var propLoc = cProp.GetLocation(c);
46 | cInfo.Properties.Add( new DataSchemaPropertyInfo() {
47 | ID = cProp.ID,
48 | Name = cProp.Name,
49 | DataTypeID = cProp.DataType.ID,
50 | DerivedFromPropertyID = propLoc.Location==PropertyValueLocationType.Derived ? propLoc.DerivedFrom.Property.ID : null
51 | } );
52 | }
53 | res.Classes.Add(cInfo);
54 | }
55 | foreach (var r in Schema.Relationships.Where(r=>r.ID!=null && !r.Reversed) ) {
56 | var relInfo = new DataSchemaRelationshipInfo() {
57 | ID = r.ID,
58 | SubjectClassID = r.Subject.ID,
59 | ObjectClassID = r.Object.ID,
60 | PredicateName = r.Predicate.Name,
61 | ObjectMultiplicity = r.Multiplicity,
62 | SubjectMultiplicity = r.ReversedRelationship.Multiplicity
63 | };
64 | res.Relationships.Add(relInfo);
65 | }
66 |
67 | return res;
68 | }
69 |
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/ApiException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Web;
21 | using System.Net;
22 | using System.ServiceModel;
23 | using System.ServiceModel.Web;
24 | using System.Runtime.Serialization;
25 |
26 | namespace NI.Data.Storage.Service {
27 |
28 | public class ApiException : ApplicationException {
29 |
30 | public HttpStatusCode StatusCode { get; private set; }
31 |
32 | public string ErrorId { get; private set; }
33 |
34 | public ApiException(string msg, HttpStatusCode code) : this( msg, code, null) { }
35 |
36 | public ApiException(string msg, HttpStatusCode code, string errorCode) : this( msg, code, errorCode, null ) {
37 | }
38 |
39 | public ApiException(string msg, HttpStatusCode code, string errorCode, Exception inner) : base( msg, inner ) {
40 | StatusCode = code;
41 | ErrorId = errorCode;
42 | }
43 | }
44 |
45 | [DataContract(Name = "error")]
46 | public class ApiFault {
47 |
48 | [DataMember]
49 | public string Message { get; set; }
50 |
51 | public ApiFault(string msg) {
52 | Message = msg;
53 | }
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/IStorageService.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.ServiceModel;
21 | using System.ServiceModel.Web;
22 | using System.Xml.Serialization;
23 | using System.ComponentModel;
24 |
25 | using NI.Data.Storage.Service;
26 | using NI.Data.Storage.Service.Actions;
27 | using NI.Data.Storage.Service.Schema;
28 |
29 | namespace NI.Data.Storage.Service {
30 |
31 | [ServiceContract]
32 | public interface IStorageService {
33 |
34 | [OperationContract]
35 | [WebInvoke(UriTemplate = "/schema", Method = "GET")]
36 | [FaultContract(typeof(ApiFault))]
37 | [Description("Get data schema (classes, properties)")]
38 | GetDataSchemaResult GetDataSchema();
39 |
40 | [OperationContract]
41 | [WebInvoke(UriTemplate = "/load/rows?q={relex}&totalcount={totalcount}", Method = "GET")]
42 | [FaultContract(typeof(ApiFault))]
43 | [Description("Load storage data as rows collection by query (relex expression)")]
44 | LoadRowsResult LoadRows(string relex, bool totalcount);
45 |
46 | [OperationContract]
47 | [WebInvoke(UriTemplate = "/load/values?q={relex}&totalcount={totalcount}", Method = "GET")]
48 | [FaultContract(typeof(ApiFault))]
49 | [Description("Load storage data as values collection by query (relex expression)")]
50 | LoadValuesResult LoadValues(string relex, bool totalcount);
51 |
52 | [OperationContract]
53 | [WebInvoke(UriTemplate = "/data/{tableName}", Method = "POST")]
54 | long? InsertRow(string tableName, DictionaryItem data);
55 |
56 | [OperationContract]
57 | [WebInvoke(UriTemplate = "/data/{tableName}/{id}", Method = "PUT")]
58 | void UpdateRow(string tableName, string id, DictionaryItem data);
59 |
60 | [OperationContract]
61 | [WebInvoke(UriTemplate = "/data/{tableName}/{id}", Method = "DELETE")]
62 | void DeleteRow(string tableName, string id);
63 |
64 | [OperationContract]
65 | [WebInvoke(UriTemplate = "/data/{tableName}/{id}", Method = "GET")]
66 | DictionaryItem LoadRow(string tableName, string id);
67 |
68 | [OperationContract]
69 | [WebInvoke(UriTemplate = "/delete?q={relex}", Method = "GET")]
70 | int DeleteRows(string relex);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/Schema/DataRowItem.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Runtime.Serialization;
21 | using System.Xml.Serialization;
22 | using System.Data;
23 | using System.Threading.Tasks;
24 | using System.Globalization;
25 |
26 | namespace NI.Data.Storage.Service.Schema {
27 |
28 | [Serializable]
29 | public class DataRowItem : ISerializable {
30 | DataRow DataRow;
31 |
32 | public DataRowItem(DataRow r) {
33 | DataRow = r;
34 | }
35 |
36 | public void GetObjectData(SerializationInfo info, StreamingContext context) {
37 | foreach (DataColumn c in DataRow.Table.Columns) {
38 | if (DataRow.IsNull(c)) {
39 | info.AddValue(c.ColumnName, null, c.DataType);
40 | } else {
41 | var val = DataRow[c];
42 | info.AddValue(c.ColumnName, val, c.DataType);
43 | }
44 | }
45 | }
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/Schema/DictionaryItem.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Runtime.Serialization;
21 | using System.Xml.Serialization;
22 | using System.Data;
23 | using System.Threading.Tasks;
24 | using System.Globalization;
25 | using System.Security.Permissions;
26 |
27 | namespace NI.Data.Storage.Service.Schema {
28 |
29 | [Serializable]
30 | public class DictionaryItem : ISerializable {
31 | public IDictionary Data;
32 |
33 | public DictionaryItem() {
34 | Data = new Dictionary();
35 | }
36 |
37 | public DictionaryItem(IDictionary data) {
38 | Data = data;
39 | }
40 |
41 | //[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.SerializationFormatter)]
42 | protected DictionaryItem(SerializationInfo info, StreamingContext context) {
43 | var e = info.GetEnumerator();
44 | Data = new Dictionary();
45 | while (e.MoveNext()) {
46 | Data[e.Name] = e.Value;
47 | }
48 | }
49 |
50 | public void GetObjectData(SerializationInfo info, StreamingContext context) {
51 | foreach (var entry in Data) {
52 | if (entry.Value == null || DBNull.Value.Equals(entry.Value))
53 | continue;
54 |
55 | info.AddValue(entry.Key, entry.Value, entry.Value.GetType());
56 | }
57 | }
58 |
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/Schema/LoadRowsResult.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Xml.Serialization;
21 | using System.Runtime.Serialization;
22 | using System.Data;
23 | using System.ComponentModel;
24 | using System.Threading.Tasks;
25 |
26 | namespace NI.Data.Storage.Service.Schema {
27 |
28 | [DataContract(Name = "rowsResult")]
29 | public class LoadRowsResult {
30 |
31 | [DataMember(Name = "data")]
32 | public RowList Data { get; set; }
33 |
34 | [DataMember(Name = "totalcount", EmitDefaultValue=true)]
35 | [DefaultValue(null)]
36 | public int? TotalCount { get; set; }
37 |
38 | public LoadRowsResult() {
39 | }
40 |
41 | }
42 |
43 | [CollectionDataContract(ItemName = "row")]
44 | public class RowList : List { }
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/NI.Data.Storage/Service/Schema/LoadValuesResult.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Open NIC.NET library (http://nicnet.googlecode.com/)
4 | * Copyright 2013-2014 Vitalii Fedorchenko
5 | * Copyright 2014 NewtonIdeas
6 | * Distributed under the LGPL licence
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | #endregion
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Xml.Serialization;
21 | using System.Runtime.Serialization;
22 | using System.Data;
23 | using System.ComponentModel;
24 | using System.Threading.Tasks;
25 |
26 | namespace NI.Data.Storage.Service.Schema {
27 |
28 | [DataContract(Name = "valuesResult")]
29 | public class LoadValuesResult {
30 |
31 | [DataMember(Name="columns")]
32 | public string[] Columns { get; set; }
33 |
34 | [DataMember(Name = "data")]
35 | public IList