Posts

c# - EF6 Updating 3 tables in one go -

i have database 3 tables table customer customerid (pk) name table order orderid (pk) customerid (fk) orderdate table orderdetailline orderdetaillineid orderid (fk) price productcode what in entity framework add 1 customer, add several different orders, each many orderdetailline relating first customer inserted. have hooked relationship in sql server , imported them ef model. no problems. can insert 1 customer , many orders , orderdetailline first time records inserted ok correct databse tables i looping around customer , orders in file adding adding customer , orders database but when want add order same customer( getting primary key violation on customer customerid). ef trying re-insert same customer after initial context.savechanges(); so, how stop ef trying add same customer when using same datacontext? i have been going around in circles hours , getting same error {"the insert statement conflicted foreign key constra...

c# - Display different values of one enumerator list into different sub menu of menu list -

i have enum follows [it prototype] public enum class alphabets { none=0, a, e, i, o, u, b, c, d, f, g, noun, adj, verb, nosign }; i want display enum contents menu item such that, main menu "english" contains sublist vowels, letters, grammer , these sublist contains element follows, english - vowels - a, e, i, o, u - letters - b, c, d, f, g, - grammer - noun, adj, verb possible have 1 enum , sort across different sub menu of menu list or different menu list? you can notate each enum display groupname when enumerate through them, groupname , sort accordingly i use these extension methods values //gets attributes enum public static t getattribute<t>(this enum value) t : attribute { if (value == null) { throw new argumentnullexception(); } var type = value.gettype(); var memberinfo = type.getmember(value.tostring()); ...

node.js - facebook login error - using MEAN -

i new mean. i've been trying create 'facebook' login new mean application. making use of strategy from: "passport-facebook". the code user.js file, i've created new schema facebook users follows: var mongoose = require('mongoose'); var fbuserschema = mongoose.schema({ id: string, token: string, email: string, name: string }); var fbuser = mongoose.model('fbuser', fbuserschema); my passport.js file has this: var fbuser = mongoose.model('fbuser'), facebookstrategy = require('passport-facebook').strategy; module.exports = function(){ passport.serializeuser(function (user, done) { if (user) { done(null, user.id); } }); passport.deserializeuser(function (id, done) { user.findone({_id: id }).exec(function (err, user) { if (user) { return done(null, user); } else { return done(null, false); ...

c - How can I delay in a Linux interrupt handler (I know sleeping usually not possible) -

i'm working on embedded linux arm system needs react power failure signal turning off power supplies (via gpio control) in specific sequence. process needs start possible, i've installed interrupt handler detect power failure. the problem need introduce little bit of delay between turning each supply off. understand delays not allowed in interrupt handler, it's totally okay if handler never returns (power failing!). i'm trying introduce delay using method described in this post , can't life of me cause measurable delay (observed on oscilloscope). what doing wrong, , how can right? what follows relevant code. /* function sets en_gpio low, waits until pg_gpio goes low. */ static inline void powerdown(int en_gpio, int pg_gpio) { /* bring enable line low. */ gpio_set_value(en_gpio, 0); /* loop until power goes low. */ while (gpio_get_value(pg_gpio) != 0); } /* attempt @ delay function. */ #define delay_count 1000000000 static void delay(vo...

How to match two columns in Excel -

Image
i trying match 2 columns, column (2, 3, 4, 5, 5, 6, 7) , column b (2, 3, 4, 5, 6, 7) using if(iserror(match(a1,$b$1:$b$8,0)),"",a1) . the formula matches values correctly fives. match both 5's in column single 5 in column b. whereas expected pick 1 5 in column , matching in column b leaving other 5 pending. have alternative formula 1 above? thanks assuming copying formula down in column, use countif see if number has occurred in column:- =if(or(iserror(match(a2,$b$2:$b$7,0)),countif(c$1:c1,a2)),"",a2) (i adding headers , starting in row 2).

c# - Getting error Type 'System.String' is not supported for deserialization of an array -

i'm having issues deserializing nested array of json objects in c# using javascriptdeserializer here code using (stream s = request.getresponse().getresponsestream()) { using (streamreader sr = new streamreader(s)) { string jsondata = sr.readtoend(); var workout = ser.deserialize<clserviceoutput1>(jsondata); } } here jsondata {"data":"50951","filedata":[37,80,68,70,45,49,46,51,13,37,226,227,207,211,13,10],"mailitem":null,"status":"success","turnaroundtime":null} here class public class clserviceoutput1 { public string data { get; set; } public string filedata { get; set; } public string mailitem { get; set; } public string status { get; set; } public string turnaroundtime { get; set; } } fileda...

mysql - Convert JSON to Excel file with php pdo -

i have file give me json output mysql database: <?php require 'core/init.php'; $general->logged_out_protect(); $username = htmlentities($user['username']); $user_id = htmlentities($user['id']); try { $result = $db->prepare('select id,br,sufiks,kupac,datum,rok,status racuni user_id=:user_id'); $result->bindparam(':user_id', $user_id); $result->execute(); //$res = $result->fetchall(pdo::fetch_assoc); /* extract information $result */ foreach($result $r) { $temp = array(); // following line used slice pie chart $temp['id'] = (int) $r['id']; $temp['br'] = $r['br'].$r['sufiks']; $temp['kupac'] = (string) $r['kupac']; $temp['datum'] = (string) $r['datum']; $temp['rok'] = (string)$r['rok']; $temp['statu...