diff --git a/APIClient/Connector/V1Connector.cs b/APIClient/Connector/V1Connector.cs
index ce8451b..087fa40 100644
--- a/APIClient/Connector/V1Connector.cs
+++ b/APIClient/Connector/V1Connector.cs
@@ -513,6 +513,11 @@ ICanGetConnector ICanSetEndpointOrGetConnector.UseEndpoint(string endpoint)
return this;
}
+
+ public FluentQuery Query(string assetTypeName)
+ {
+ return new Services(this.Build()).Query(assetTypeName);
+ }
}
#endregion
@@ -587,6 +592,7 @@ public interface ICanSetProxyOrEndpointOrGetConnector : ICanSetEndpoint, ICanGet
/// The ProxyProvider containing the proxy URI, username, and password.
/// ICanSetEndpointOrGetConnector
ICanSetEndpointOrGetConnector WithProxy(ProxyProvider proxyProvider);
+ FluentQuery Query(string assetTypeName);
}
public interface ICanSetEndpointOrGetConnector : ICanGetConnector
diff --git a/APIClient/Model/Asset/Asset.cs b/APIClient/Model/Asset/Asset.cs
index 6b55daa..802ad01 100644
--- a/APIClient/Model/Asset/Asset.cs
+++ b/APIClient/Model/Asset/Asset.cs
@@ -1,15 +1,19 @@
using System;
using System.Collections.Generic;
+using System.Dynamic;
using System.Linq;
namespace VersionOne.SDK.APIClient
{
- public class Asset
+ public class Asset : DynamicObject
{
private Oid oid = Oid.Null;
private readonly IDictionary attributes = new Dictionary();
private readonly IAssetType assetType;
private readonly AssetList children = new AssetList();
+ protected string AssetBasePrefix { get; set; }
+ private IMetaModel metaModel;
+ private IServices services;
public IAssetType AssetType
{
@@ -56,6 +60,20 @@ public Asset(IAssetType assetType)
this.assetType = assetType;
}
+ public Asset(string basePrefix, IMetaModel metaModel, IServices services)
+ {
+ Configure(basePrefix, metaModel, services);
+ }
+
+ public void Configure(string basePrefix, IMetaModel metaModel, IServices services)
+ {
+ this.AssetBasePrefix = basePrefix;
+ this.metaModel = metaModel;
+ this.services = services;
+ }
+
+ public object this[string name] => GetValueByName(name);
+
public void SetAttributeValue(IAttributeDefinition attribdef, object value)
{
EnsureAttribute(attribdef).SetValue(value);
@@ -153,5 +171,49 @@ public Attribute EnsureAttribute(IAttributeDefinition attribdef)
return attrib;
}
+
+ #region DynamicObject members
+
+ public override bool TryGetMember(GetMemberBinder binder,
+ out object result)
+ {
+ var attribute = GetAttributeByName(binder.Name);
+ result = GetAttribute(attribute).Value;
+ return result != null;
+ }
+
+ public override bool TrySetMember(SetMemberBinder binder, object value)
+ {
+ var attribute = GetAttributeByName(binder.Name);
+ if (attribute != null)
+ {
+ SetAttributeValue(attribute, value);
+ return true;
+ }
+ return false;
+ }
+
+ #endregion
+
+ public IAttributeDefinition GetAttributeByName(object fieldName)
+ {
+ return metaModel.GetAttributeDefinition(AssetBasePrefix + "." + fieldName);
+ }
+
+ public object GetValueByName(string fieldName)
+ {
+ var attribute = GetAttributeByName(fieldName);
+ return GetAttribute(attribute).Value;
+ }
+
+ public void SaveChanges()
+ {
+ services.Save(this);
+ }
+
+ public void SaveChanges(string comment)
+ {
+ services.Save(this, comment);
+ }
}
}
\ No newline at end of file
diff --git a/APIClient/Query/FluentQuery.cs b/APIClient/Query/FluentQuery.cs
new file mode 100644
index 0000000..7734e98
--- /dev/null
+++ b/APIClient/Query/FluentQuery.cs
@@ -0,0 +1,170 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace VersionOne.SDK.APIClient
+{
+ public class FluentQuery
+ {
+ private IMetaModel metaModel;
+ private IServices services;
+ public Query RawQuery { get; set; }
+ public string AssetTypeName { get; set; }
+ public List> WhereCriteria { get; set; }
+ public List