I would like to know what the best way is to create a custom lookup for a field in my table, my situation is as following:
I have Form A which has a datasource to Table A, a field on that datasource has a lookup method:
public void lookup(FormControl _formControl, str _filterStr)
{
changeCompany(companyInfo.DataArea)
{
super(_formControl, _filterStr);
}
}
The field has an EDT, which has an relation to a Table.
The table has multiple fields, 1 of them is field: GroupType (Enum), with 2 options: Suppliers and Customers.
Form A is showing all records, both with Suppliers and Customers, but i would like to filter on the records with only has the value Suppliers in Column C.
Based on the information above, what is the best way to create this custom lookup?
You can create Related field fixed relation between your tables
TableB = TableB.Id
Enum::Suppliers = TableB.GroupType
Or create a custom lookup
and set a range for field GroupType.
Related
I have a table the only has an Id column in SQL. It is an Auto-Increment column. It is used to keep track of a booking number sequence to be sent to an outside system. In SQL I use this to insert a new record:
insert into bookingnumbers default values
I would like to use entity framework and get the Next available Id. I have tried this:
private async Task<long> GetNextBookingNumberAsync()
{
BookingNumbers bookingNumber = default;
GhanemContext.BookingNumbers.Add(bookingNumber);
await GhanemContext.SaveChangesAsync();
return bookingNumber.Id;
}
However, booking number is just null and I get:
ArgumentNullException: Value cannot be null. Parameter name: entity
Any help would be greatly appreciated!
I have three Tables:
Teachers
PK: A_pk
Students
PK: B_pk
Post
PK: C_pk
FK: A_pk
FK: B_pk
I have a Website page where users write different posts.
When teachers post in that group, I will insert data into the Post table like this:
A_pk = teacherName
C_pk = Post_text
When students post in that group, I will insert data into the Post table like this:
B_pk = studentName
C_pk = Post_text.
Reason is that I want to keep record which user posted data in my group.
Now the Question is how to insert record in Post table?
You cannot have one field in your table be a foreign key to two different tables. What you need to do is change your data structure to either hold your students and teachers in the same table and use that primary key in your Post table, or to have two columns in your Post table - one for the Teacher primary key and one for the Student primary key and populate the appropriate one based on who made the post.
There is absolutely no need nor reason to have the ID of two different tables within the same field. Doing so would be bad design.
Finally--- I found the Solution.
Actually its very simple... Like you can have nullable FK.so when you insert for student then A_PK can be null and vice versa. –
If teacher posted data in group than
if(A_pk != null) { Insert A_pk and Insert C_pk }
If student posted data in group than
else if(B_pk != null) { Insert B_pk and Insert C_pk }
Thanks alot Sir
KumarHarsh 1 hour ago
Cassandra support updating specific value in Collection by syntax
ALTER TABLE users ADD todo map<timestamp, text>
UPDATE users SET todo['2012-10-2 12:00'] = 'throw my precious into mount doom'
WHERE user_id = 'frodo';
http://www.datastax.com/documentation/cql/3.0/cql/cql_using/use_map_t.html
Did not see any example of using QueryBuilder to update specific row in Map. How it can be done?
I think you have several options.
1/ Build your own query based on the CQL one.
Example: Consider that you have a table named Interactions and in your schema a column of type named 'attributes'.
String update ="UPDATE demo.Interactions SET attributes=attributes + {'i':'j'} where id='ff';
SimpleStatement statement = new SimpleStatement(update);
session.execute(statement);
2/ Use Java API.
Java API is not that documented indeed.
Let's take an example
a- Create an update object using queryBuilder
Update update = QueryBuilder.update(keyspace, tableName);
b- Then populate with 'put' or 'putAll' functions. put/putAll will add/update content
update.with(QueryBuilder.putAll(key, map));
To remove a key, set the content of a key to null, like:
for (Object item : map.keySet()) {
update.with(
QueryBuilder.put(columName, item, null)
);
}
Then execute the query.
Following methods are available for different types:
LIST:
QueryBuilder.appendAll(...)
QueryBuilder.discardAll(...)
SET:
QueryBuilder.addAll(...)
QueryBuilder.removeAll(...)
MAP:
QueryBuilder.putAll(...)
QueryBuilder.put(...)
The list is not exhautive.
Have a look in QueryBuilder class if you do not find what you are looking for.
Best regards and best luck with Cassandra.
I am using lightswitch and i have to join 3 tables in my query. Table A join Table B join table C where tableC.id == 10
partial void Query2_PreprocessQuery(int? dept, ref IQueryable query)
{
query = query.Join(Employee_Personal_Infoes, b => b.Employee_Personal_Info1.Emp_id, (b));
}
First off, if you add relationships between your tables, you shouldn't ever need to do manual joins. You would then just use the navigation properties that get created when you add the relationships.
Second, you can't change the shape of the entity in a query, or return a set of different entities. If your query is based say on a Customer entity, you can't return a query of CustomerAdresses, or a Client entity from that query. The query can only return a filtered set of the same entity that the query is based on.
Does that make sense?
I have 3 tables. Blog and Tag have a many to many relationship. BlogTag is a junction table with a quantity column.
**Blog**
BlogID
Title
**Tag**
TagID
Name
**BlogTag**
BlogID
TagID
Quantity
I'm not sure how I handle the quantity column. I'd like it to store how many Blogs have a certain Tag Name
How do I deal with the quantity column when adding a new blog that has tags?
Thanks!
Well, you'd need to calculate the quantity:
var q = (from b in Context.Blogs
where b.BlogTags.Any(t => t.Tag.TagId == someId)
select b).Count();
So you:
1. Add the blog
2. SaveChanges
3. For each tag on the new blog:
1. Calculate the quantity, as above.
2. Update the BlogTag.Quantity.
4. SaveChanges