Dynamic values in Simple.Data - simple.data

Please see below line of code for assistance.
private static readonly dynamic db= Database.OpenNamedConnection("DefaultConnectionString");
var idRecord = db.TableName.FindAll(db.TableName.phoneNo == phoneNo && db.TableName.password == pass).FirstOrDefault();
My question is, how can I see the value of db.TableName.phoneNo during Debug.
Any help is welcome.
Thanks.
Liaqat

The only way to debug this is to have the query output to the console. Then you can run it in your database. For more information, see this question. How to log generated sql queries out of Simple.Data ORM for .NET

Related

Devexpress End user Report Designer: Datasource binding is null when retrieve report from database

I am creating reporting server using asp.net mvc web api. I am retrieving data from web api retriving report using XRDesignForm object of devexpress. I am posting back report data to web api. what issue i am facing is, and if i use xtrareport obejct and bind datasource manually it work fine.i.e.
XtraReport report = new XtraReport();
report.DataSource = setupSummary.FillDataSet();
report.DataMember = ((DataSet)report.DataSource).Tables[0].TableName;
designForm.OpenReport(report);
//designForm.Show();
designForm.ShowDialog(this);
I can successfully mainuplate this report and can save into database,
But as shown in articles for ReportStorage, if i only retrieve report from database using report name from server, datasource is always null.i.e.
XRDesignForm designForm = new XRDesignForm();
string url = GetSelectedUrl();
if (!string.IsNullOrEmpty(url))
designForm.OpenReport(url);
designForm.ShowDialog(this);
It seems that when saving dynamic report into database (as binary), It loss data source bindings.
please help me for this.
thanks
Aqdas, thank you very much.
There is a similar error in the report layout,
My solution is, after the layout again set DataSource
XtraReport rep = null;
rep = new rptReqVac();
Stream layoutStream = null;
layoutStream = mGetLoyoutStream(id);
rep.LoadLayout(layoutStream);
rep.DataSource = new dsREQPrintVac();
reportDesigner.OpenReport(rep);
Hope it will help someone :-)
Finally after spending lot of time, i had fixed this, Issue is actually when you save report to database as binary, it skip DataAdapter for report. so before saving you need to do first null to dataadapter or report and then assaing again before you get buffer for report layout.
Hope it will help someone :-)

Start SQL Job from X++ Job in Axapta

I want to trigger an SQL job which runs an SSIS package from an AX Job, I successfully ran SQL code fetching some records from an SQL table by creating a menu item for the job and have it run on the server instead of the client but the following code runs without errors but the Job's not started?
CODE:
static void TriggerAllocation(Args _args)
{
UserConnection userConnection;
Statement statement;
str sqlStatement;
SqlSystem sqlSystem;
SqlStatementExecutePermission sqlPermission;
;
sqlSystem = new SqlSystem();
sqlStatement = "EXEC MSDB.dbo.sp_start_job #Job_Name = 'MyJob'";
userConnection = new UserConnection();
statement = userConnection.createStatement();
sqlPermission = new SqlStatementExecutePermission(
sqlStatement);
sqlPermission.assert();
statement.executeQuery(sqlStatement);
CodeAccessPermission::revertAssert();
I can't find any more clues in e.g. eventviewer, SQL logs as for what went wrong..
Kind regards,
Mike
[UPDATE] Thanks to Alex K I solved it!
using
statement.executeUpdate(sqlStatement);
instead of
statement.executeQuery(sqlStatement);
did the trick!
Keep in mind that running the job directly from AX won't work despite: server static void
You'll have to create an Menu Item of type action with property RunOn=Server
I should have given my comment as an answer but wasn't paying attention:
Try server static void Trigger... and perhaps statement.executeUpdate(...) instead of executeQuery
Calling EXEC from executeQuery is not supported.
See this question:
How to get the results of a direct SQL call to a stored procedure?

Can't get profile data in Application_Start

I have the following code at some point in Application_Start
MembershipUserCollection users = Membership.GetAllUsers();
foreach (MembershipUser u in users)
{
ProfileBase profile = ProfileBase.Create(u.UserName, false);
if (profile["Index"] != null)
{
// Some code
}
}
The problem is that when i try to access the profile properties I get "Request is not available in this context" httpException. I have tried using profile.GetPropertyValue but no luck also.
Why does profile need the request object and how can I get this to work?
EDIT:
I have looked into the .NET code and found that at some point SqlProfileProvider.GetPropertyValuesFromDatabase(string userName, SettingsPropertyValueCollection svc) is called, inside of which rests this string of code:
if (!current.Request.IsAuthenticated)
Apparently this will never work if not in request context. The workaround descripbed in Onur's answer will work fine.
Apparently you are trying to access request object which is not possible in your case.
Please take a look following link and apply one of workarounds if possible.
http://mvolo.com/iis7-integrated-mode-request-is-not-available-in-this-context-exception-in-applicationstart
and if you give more information what are you trying to achieve we can find another way.
You could get the "string value" properties by querying the aspnet_Profiles table and parsing the string.
SELECT [UserName]
,[PropertyNames]
,[PropertyValuesString]
FROM [aspnet_Profile]
LEFT JOIN [aspnet_Users] on [aspnet_Users].UserId = [aspnet_Profile].UserId
The PropertyValuesString can be parsed with a bit of code. This link should explain the format in detail https://msdn.microsoft.com/en-us/library/aa478953.aspx#persistence_format.

Unable to fetch object by id in JDOQL

I am pretty naive to hbase and JDO. I was trying to use
Query q = pm.newQuery(MyClass.class, "id == " + taskId);
List<MyClass> taskList = (List<MyClass>)q.execute();
But to my disappointment the list I am receiving is blank. although the taskId in the argument is already present.
Any kind of help would highly appreciable.
Thanks in advance!!
If fetching an object by id then would make way more sense to call
pm.getObjectById(...)
and if using a query, it would be normal to look at the log
try
taskList = (List) pm.detachCopy(taskList);
after your code

llblgen: How do i filter?

Im having some problems with filtering data with LLBLGen. I have an EmployeeEntity where i want to fetch the data filtering by string CustomerNumber. CustomerNumber is not Primary Key. I guess i have to use the IPredicateExpression, but how?
EDIT: Im using the Adapter Model.
You'll need to do something like this:
IRelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(EmployeeFields.CustomerNumber == "123");
You can find a much more in-depth discussion here.
EmployeeCollection employees = new EmployeeCollection();
employees.GetMulti(EmployeeFields.CustomerNumber == "123");
You can fetch lists using DataAccessAdapter.FetchEntities. The filtering can be done via PredicateExpressions. A nice documentation of the predicate system can be found here.

Resources