I have a controller class and inside a method of the controller class, I have List Defined as below.
List<TrackedStoreProductsViewModel> currTrackProds = _context.Tracked_Products.Select(p => new TrackedStoreProductsViewModel()
{
TrackedProducts = p,
currentPrice = _context.Store_Products.Where(x => trackedId.Contains(x.product_id)).FirstOrDefault(s => s.product_id == p.product_id).Product_Price_History.OrderByDescending(pr => pr.price_timestamp).Select(pr => pr.price).FirstOrDefault(),
userEmailId = _context.User_Accounts.FirstOrDefault(u => u.account_number == p.account_number).email_id,
userFirstName = _context.User_Info.FirstOrDefault(u => u.account_number == p.account_number).first_name
}
).ToList();
Here I am getting the following exception error
Here the exception error is 'Unknown column 't.Store_Productsproduct_id' in 'field list'.
I checked all the models related to this, set up a breakup point stepped in still couldn't find where it is defined that way? Can someone suggest me an approach I can possibly follow to fix this issue?
Related
I am new to PQ and I want to get data from REST API.
The API uses pagination and in the 1st quary it returns two fileds. Table contains only 100 records.
IssueList = Table
NextBookmark = value
The url /issues?bookmark=[value] to get another page of issues.
I am trying to use https://learn.microsoft.com/en-us/power-query/samples/trippin/1-odata/readme tutorial to create connector but fails to get values from another page.
Code below:
Table.GenerateByPage = (getNextPage as function) as table =>
let
listOfPages = List.Generate(
() => getNextPage(null), // get the first page of data
(lastPage) => lastPage <> null, // stop when the function returns null
(lastPage) => getNextPage(lastPage) // pass the previous page to the next function call
),
// concatenate the pages together
tableOfPages = Table.FromList(listOfPages, Splitter.SplitByNothing(), {"Column1"}),
firstRow = tableOfPages{0}?
in
// if we didn't get back any pages of data, return an empty table
// otherwise set the table type based on the columns of the first page
if (firstRow = null) then
Table.FromRows({})
else
Value.ReplaceType(
Table.ExpandTableColumn(tableOfPages, "Column1", Table.ColumnNames(firstRow[Column1])),
Value.Type(firstRow[Column1])
);
GetAllPagesByNextLink = (url as text) as table =>
Table.GenerateByPage((previous) =>
let
// if previous is null, then this is our first page of data
nextLink = if (previous = null) then url else Value.Metadata(previous)[NextLink]?,
// if NextLink was set to null by the previous call, we know we have no more data
page = if (nextLink <> null) then GetPage(nextLink) else null
in
page
);
GetPage = (url as text) as table =>
let
response = Web.Contents(url, [ Headers = DefaultRequestHeaders ]),
body = Json.Document(response),
nextLink = GetNextLink(body),
data = Table.FromRecords(body[IssueList])
in
data meta [NextLink = nextLink];
GetNextLink = (response) as nullable text => Record.FieldOrDefault(response[NextBookmark], "NextBookmark");
PQ.Feed = (url as text) as table => GetAllPagesByNextLink(url);
Can anyone help me out?
Thanks in advance for words of advice :)
I want to edit a message, but it's only updated when i changed this message _id. Can someone provide me how to do it, here is my code:
const onSend = useCallback((messagesToSend = []) => {
if(editMessage != null){
setEditMessage()
const m = messagesToSend[0]
const newMessages = [...messages]
const index = newMessages.findIndex(mes => mes._id === editMessage._id);
console.log('index: ', index)
if(index > -1){
newMessages[index].text = m.text // => ***i only edit the text***
// newMessages[index]._id = uuid.v4() => ***this working if changed _id***
console.log('newMessages', newMessages[index]) // => ***new message changed it's text but the bubble not change when re-render***
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
setMessage(newMessages)
}
}else{
setReplyMessage()
appendMessage(messagesToSend)
}
})
It looks like you're using useCallback without a dependency array. This means that any dependencies that you rely on will be memoized and won't update when you run the function.
You should add messages, editMessage, and maybe setMessage and appendMessage, to the dependency array. Like so:
const onSend = useCallback(
(messageToSend = []) => etc,
[messages, editMessage, setMessage, appendMessage]);
That's the first thing I would try
ok i found problem, in MessageText the function componentShouldUpdate need modify a bit
I am trying to create a LinkedHashMap and populate it with a DateTime as the key and a List as the value in my flutter app. I keep running into problems with creating this.
Here is what I am trying right now without success:
List<dynamic> _getEventsForDay(DateTime day) {
for (int i = 0; i < eventDoc.length; i++ ) {
if (day.year == eventDate.year && day.day == eventDate.day && day.month == eventDate.month) {
List<dynamic> eventList = [];
eventList.add(eventDoc[i].agencyId);
eventList.add(eventDoc[i].agentId);
eventList.add(eventDoc[i].eventDate);
eventList.add(eventDoc[i].eventDescription);
eventList.add(eventDoc[i].eventDuration);
eventList.add(eventDoc[i].eventName);
eventList.add(eventDoc[i].eventStartTime);
return kEvents.putIfAbsent(eventDateUTC, () => eventList);
}
}
}
Everything is working except the last line and the putIfAbsent call. The eventDateUTC and the eventList both have values.
I am getting this error when I try to execute the
return kEvents.putIfAbsent(eventDateUTC, () => eventList);
line. When this line executes I get this error:
The method 'putIfAbsent' was called on null.
Receiver: null
Tried calling: putIfAbsent(Instance of 'DateTime', Closure: () => List<dynamic>)
kEvents is declared like this:
LinkedHashMap<DateTime, List> kEvents;
I am sure I am missing something small but I don't have enough experience with flutter to know what it is. Please help if you can.
i want to ask something related with php activerecord
here'se my code
public function validate()
{
$log = Login::find(1);
$login = new Login(array(
'id' => 1,
'user' => $_POST['user'],
'pass' => $_POST['pass']
));
if ($this->user = $log->user AND $this->pass = $log->pass | $log->user = $this->user AND $log->pass = $this->pass)
{
APP::redirect('dashboard.index');
}else{
APP::redirect('dashboard.login');
}
}
i wonder why my code always redirect to dahsboard.index although the value from input form and database are different. is there something i missed? and english isn’t my first language, so please excuse any mistakes. thanks before.
You seem to have confused = (assignment) with == (comparison). So you'd get a lot of 'TRUE' in that if.
I am a Scalatra beginner and I have the following route:
get("/todos") {
contentType = formats("json")
val userid : Int = params.getOrElse("userid", halt(400)).toInt
val limit : Int = params.getOrElse("limit", "0").toInt
val offset : Int = params.getOrElse("offset", "0").toInt
if(limit != 0 && offset != 0)
from(TodoDb.todos)(todo => where(todo => todo.userid == userid) select(todo)).toList
else {
from(TodoDb.todos)(todo => where(todo => todo.userid == userid) select(todo) orderBy(todo.modified)).page(offset, limit).toList
}
}
I can't compile it, I got the following error messages:
[info] Compiling 1 Scala source to /home/coelho/www/p.zomg.hu/gfmwa-todo-app/target/scala-2.10/classes...
[error] /home/coelho/www/app/src/main/scala/hu/gfmwa/todoapp/TodoScalatraServlet.scala:25: missing parameter type
[error] from(TodoDb.todos)(todo => where(todo => todo.userid == userid) select(todo)).toList
[error] ^
[error] /home/coelho/www/app/src/main/scala/hu/gfmwa/todoapp/TodoScalatraServlet.scala:27: missing parameter type
[error] from(TodoDb.todos)(todo => where(todo => todo.userid == userid) select(todo) orderBy(todo.modified)).page(offset, limit).toList
[error] ^
[error] two errors found
[error] (compile:compile) Compilation failed
I learn from here: http://squeryl.org/selects.html and here: http://squeryl.org/pagination.html
I can't see parameter type information on these pages, I can't figure out, what can be the problem. What I am doing wrong?
where doesn't expect a function inside ( todo=> ), but rather just a boolean thing. So, to make your code work, write something like from(TodoDb.todos)(todo => where(todo.userid === userid) select.
BTW, I suggest to be immediately cautious when seeing a code fragment like (todo => where (todo => (double "todo" definition).