1) 예 2) AX 내에서 정보에 액세스하려면이 항목이 필요합니다.
using Microsoft.Dynamics.AX.Framework.Linq.Data;
using U23 = Microsoft.Dynamics.AX.ManagedInterop;
using U22 = Microsoft.Dynamics.AX.Framework.Linq.Data;
using Microsoft.Dynamics.Portal.Application.Proxy;
마지막으로 C#의 내 액세스 레이어에 대한 기본 레이아웃입니다.
public bool UpdateSomething(Something something)
{
U23.RuntimeContext.Current.TTSBegin();
try
{
if (something.Count == 0)
{
something.Delete();
}
something.Update();
U23.RuntimeContext.Current.TTSCommit();
return true;
}
catch
{
U23.RuntimeContext.Current.TTSAbort();
return false;
}
}
그러나 당신이있어 확인 : 당신이 뭔가를 업데이트 할 경우,
public Somethings GetSomethingsById(int id)
{
Somethings retVal = new Somethings();
U22.QueryProvider provider = new U22.AXQueryProvider(null);
U22.QueryCollection<Somethings> somethings = new U22.QueryCollection<Somethings>(provider);
var somethings2 = somethings.Where(x => x.SomethingId == id);
retVal = somethings2.FirstOrDefault();
return retVal;
}
마지막 : 다음
private U23.Session _axSession = new U23.Session();
public U23.Session Connection
{
get
{
return this._axSession;
}
}
/// <summary>
/// Checks to see if the AX session is connected. If it's null we return false.
/// Then we check to see if it's logged in, then return true. Otherwise it's not logged in.
/// </summary>
public bool Connected
{
get
{
if (this._axSession == null)
{
return false;
}
else if (this._axSession.isLoggedOn())
{
return true;
}
return false;
}
}
/// <summary>
/// This connects to the AX session. If it's already connected then we don't need to connect
/// again, so we return true. Otherwise we'll try to initiate the session.
/// </summary>
/// <returns>
/// True: Connection openned successfully, or was already open.
/// False: Connection failed.
/// </returns>
public bool OpenConnection()
{
if (this.Connected)
{
return true;
}
else
{
try
{
_axSession.Logon(null, null, null, null);
return true;
}
catch
{
return false;
}
}
}
/// <summary>
/// If the session is logged on we will try to close it.
/// </summary>
/// <returns>
/// True: Connection closed successfully
/// False: Problem closing the connection
/// </returns>
public bool CloseConnection()
{
bool retVal = false;
if (this.Connection.isLoggedOn())
{
try
{
_axSession.Logoff();
retVal = true;
}
catch
{
retVal = false;
}
}
else
{
retVal = true;
}
this.Connection.Dispose();
return retVal;
}
는 AX의 특정 기능에 액세스 할 수 당신은해야합니다 업데이트 할 계획 인 경우 .ForUpdate()를 사용하여
Something
을 선택하십시오.
응용 프로그램 프록시 (예 : EPApplicationProxies)에 사용하려는 개체를 추가하고 프로젝트에서 해당 개체를 참조해야합니다.
다이나믹을 위해 어떤 어셈블리 참조가 필요합니까? –
괜찮습니다. 도와 주셔서 감사합니다 . –